/**
 * Created by hxpeng on 2017/3/24.
 */

'use strict';

    commonConfig.$inject = ["$ionicConfigProvider", "$urlRouterProvider", "$locationProvider", "storeProvider", "$compileProvider"];
    angular.module('App',[
        'ngAnimate',
        'angular-storage',
        'ngResource',
        'templates',
        'ui.router',
        'ionic',
        'ngTextTruncate',
        'App.common',
        'App.pages'
    ])
        .config(commonConfig)
        .constant('API',"http://www.hxpeng.com/kinder")
        //.constant('API',"http://192.168.1.204/kinder")
        .constant('Global', {
            default_avatarPath:'http://www.hxpeng.com/wechat/assets/img/default_head.png',
            path:{
                wechat_path: "http://www.hxpeng.com/wechat",
                img_path: "http://www.hxpeng.com/images/",
                server_wechat_test_path: "http://www.hxpeng.com/kinder/wechat/testPath",
                server_sdk_auth_path: "http://www.hxpeng.com/kinder/wechat/wechatSdkAuth"
            },
            memberType: [
                {
                    key:"teacher",
                    value:"教师"
                },
                {
                    key:"parent",
                    value:"家长"
                },
                {
                    key:"student",
                    value:"学生"
                }
            ],
            //过滤路径
            filterPath: [
                "/pageNotFound",
                "/bind/menu",
                "/bind/createParent",
                "/bind/bindTeacherInfo",
                "/bind/bindConfirm",
                "/bind/bindResult"
            ]
        })


    /**
     * 全局插件基础设置
     * @param $ionicConfigProvider
     * @param $locationProvider
     */
    function commonConfig($ionicConfigProvider, $urlRouterProvider, $locationProvider, storeProvider,$compileProvider){




        //storage 设置为会话级别，关闭浏览器即过期
        // Store defaults to localStorage but we can set sessionStorage or cookieStorage.
        storeProvider.setStore('sessionStorage');
        //其中 weixin 是微信安卓版的 localId 的形式，wxlocalresource 是 iOS 版本的 localId 形式
        $compileProvider.imgSrcSanitizationWhitelist(/^\s*(http|https|data|weixin|wxLocalresource|wxlocalresource):/);

        //ionic 不缓存页面
        //$ionicConfigProvider.views.maxCache(0);
        $ionicConfigProvider.views.transition('none');
        //$ionicConfigProvider.platform.ios.views.transition('ios');
        //$ionicConfigProvider.platform.android.views.transition('android');
        $ionicConfigProvider.platform.ios.navBar.alignTitle('center');
        $ionicConfigProvider.platform.android.navBar.alignTitle('center');
        $ionicConfigProvider.platform.ios.backButton.previousTitleText('').icon('ion-ios-arrow-thin-left');
        $ionicConfigProvider.platform.android.backButton.previousTitleText('').icon('ion-android-arrow-back');

        //取消路径中的#
        $locationProvider.html5Mode(true);
        //$urlRouterProvider.otherwise("/member/bind");
    };






/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider", "$urlRouterProvider"];
    angular.module('App.pages', [
        'ngAnimate',
        'ngAudio',
        'ui.router',
        'App.pages.bind',
        'App.pages.member',
        'App.pages.common',
        'App.pages.class',
        'App.pages.dynamic'
    ])
        .config(routeConfig);


    function routeConfig($stateProvider,$urlRouterProvider) {
        //404页面
        $urlRouterProvider.otherwise('/common/pageNotFound');
    }


})();

/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';
    angular.module('App.common', [

    ]);

})();
/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider", "$urlRouterProvider"];
    angular.module('App.pages.bind', ['App.pages.member'])
        .config(routeConfig);

    function routeConfig($stateProvider,$urlRouterProvider) {
        $stateProvider.state('bind', {
            url: "/bind",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('bind.menu', {
            url: "/menu",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/bind-menu.html',
                    controller:'BindCtrl as vm',
                }
            }
        }).state('bind.createParent', {
            url: "/createParent",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/create-parent.html',
                    controller:'CreateParentCtrl as vm',
                }
            }
        }).state('bind.bindTeacherInfo', {
            url: "/bindTeacherInfo",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/bind-teacher.html',
                    controller:'BindTeacherCtrl as vm',
                }
            }
        }).state('bind.bindConfirm', {
            url: "/bindConfirm",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/bind-confirm.html',
                    controller:'BindConfirmCtrl as vm'
                }
            }
        }).state('bind.bindResult', {
            url: "/bindResult",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/bind-result.html',
                    controller:'BindCtrl as vm'
                }
            }
        }).state('bind.createResult', {
            url: "/createResult",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/bind/create-result.html'
                }
            }
        });

        $urlRouterProvider.otherwise('/pageNotFound');
    }
})();
/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    BindConfirmCtrl.$inject = ["$scope", "AppUtils", "$location", "StoreUtils", "LoginAccountAuth", "MemberModel"];
    angular.module('App.pages.bind')
        .controller('BindConfirmCtrl', BindConfirmCtrl);

    function BindConfirmCtrl($scope,AppUtils,$location,StoreUtils,LoginAccountAuth,MemberModel) {
        var vm = this;

        LoginAccountAuth.getAccount()
            .then(function (data) {
                vm.memberVo = StoreUtils.getObj("bindMemberVo");
                vm.memberVo.openId = data.openId;

                vm.student = {};
                vm.class = {};
                vm.class = StoreUtils.getObj("class");
            });

        $scope.postMemberInfo = function(){
            MemberModel.bindWeChatInfo(vm.memberVo).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var loginAccountVo = response.loginAccountVo;
                    LoginAccountAuth.setAccount(loginAccountVo);
                    AppUtils.showAlert("绑定成功！");
                    $location.path("/member/teacherIndex");

                }
            })
        }

    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    BindCtrl.$inject = ["store", "$scope", "$state", "AppUtils", "$location", "$http", "Global", "StoreUtils"];
    angular.module('App.pages.bind')
        .controller('BindCtrl', BindCtrl);

    function BindCtrl(store,$scope,$state,AppUtils,$location,$http,Global,StoreUtils) {


        //暂搁置扫码绑定成员
        //var currentPath = $location.url();
        //if(currentPath.indexOf("#") != -1){
        //    currentPath = currentPath.split('#')[0];
        //}
        //currentPath = Global.path.wechat_path + currentPath;
        //console.log(currentPath);
        //$http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
        //    .success(function(data){
        //        wx.config({
        //            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        //            appId: data.appId, // 必填，公众号的唯一标识
        //            timestamp: data.timestamp, // 必填，生成签名的时间戳
        //            nonceStr: data.noncestr, // 必填，生成签名的随机串
        //            signature: data.signature,// 必填，签名，见附录1
        //            jsApiList: ['scanQRCode'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        //        });
        //        /**
        //         * 如果需要页面加载就执行微信sdk接口，把接口放入wx.read即可
        //         */
        //        //wx.ready(function () {
        //        //});
        //        wx.error(function(res){
        //            console.log(res);
        //            // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，
        //            // 也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
        //
        //        });
        //    })
        //    .error(function(data,header,config,status){
        //        console.log("请求微信sdk校验异常");
        //    });
        //$scope.scanQode = function(){
        //    wx.scanQRCode({
        //        needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
        //        scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
        //        success: function (res) {
        //            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
        //            alert(result);
        //            //$("input[name='jsonParams']").val(result);
        //            //$("form").submit();
        //        }
        //    });
        //}


        $scope.$on('$ionicView.enter', function(){
            $("div.item").off("click");
            $("div.item").on("click",function(){
                var obj = $(this).find("input[type='checkbox']");
                if(obj.prop('checked')){
                    obj.prop("checked","");
                }else{
                    $("div.item").find("input[type='checkbox']").prop("checked","");
                    obj.prop("checked","checked");
                }
            });
        });



        $scope.next = function(){
            if($("#parent").prop('checked')){
                $state.go("bind.createParent");
            }else if($("#teacher").prop('checked')){
                $state.go("bind.bindTeacherInfo");
            }
        }


    }

})();

/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    BindModel.$inject = ["API", "$resource"];
    angular.module('App.pages.bind')
        .service('BindModel', BindModel);

    function BindModel(API,$resource) {
        this.actions = {}
        /**
         * 和微信号绑定
         * @type {{method: string, url: string}}
         */
        this.actions.bindWeChatInfo = {
            method: 'POST',
            url: API + '/member/bindWeChatInfo'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }

})();
/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    BindTeacherCtrl.$inject = ["$scope", "AppUtils", "$location", "StoreUtils", "$http", "API"];
    angular.module('App.pages.bind')
        .controller('BindTeacherCtrl', BindTeacherCtrl);

    function BindTeacherCtrl($scope,AppUtils,$location,StoreUtils,$http,API) {

        var obj = StoreUtils.getObj("bindMemberVo");

        var vm = this;
        vm.memberVo = {};
        if(!AppUtils.isUndefinedOrNull(obj) && obj.memberType == "1"){
            vm.memberVo = obj;
        }


        $scope.submitTeacherInfo = function(){
            if(AppUtils.isUndefinedOrNull(vm.memberVo.className)){
                AppUtils.showTipsTop("班级编号不可以为空哦!");
                return;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberVo.memberName)){
                AppUtils.showTipsTop("你的名称不可以为空哦!");
                return;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberVo.memberPhone)){
                AppUtils.showTipsTop("你的手机号码不可以为空哦！");
                return;
            }
            var reMobile=/^((1[3|4|5|7|8][0-9])|(0?0?(852|853)-?))\d{8}$/;
            if(!reMobile.test(vm.memberVo.memberPhone)) {
                AppUtils.showTipsTop("请输入正确的手机号哦!");
                return;
            }
            vm.memberVo.memberType = "1";
            StoreUtils.setObj("bindMemberVo",vm.memberVo);


            $http.post(API + '/class/findClassByName', {"className":vm.memberVo.className})
                .success(function (response) {
                    var obj = response.class;
                    if(!AppUtils.isUndefinedOrNull(obj)){
                        StoreUtils.setObj("class",obj);
                        $location.path("/bind/bindConfirm");
                    }else{
                        AppUtils.showAlert("没有找到班级，请核对输入信息！");
                    }
                })
                .error(function (data) {
                    AppUtils.showAlert("请求异常，请稍后再试！");
                })
        }
    }

})();

/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    CreateParentCtrl.$inject = ["$scope", "AppUtils", "StoreUtils", "$location", "MemberModel", "LoginAccountAuth"];
    angular.module('App.pages.bind')
        .controller('CreateParentCtrl', CreateParentCtrl);

    function CreateParentCtrl($scope,AppUtils,StoreUtils,$location,MemberModel,LoginAccountAuth) {

        var obj = StoreUtils.getObj("bindMemberVo");

        var vm = this;
        vm.memberVo = {};

        $scope.submitParentInfo = function(){
            if(AppUtils.isUndefinedOrNull(vm.memberVo.memberName)){
                AppUtils.showTipsTop("家长的姓名不可以为空哦!");
                return;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberVo.memberRelType)){
                AppUtils.showTipsTop("家长的称呼不可以为空哦!");
                return;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberVo.memberPhone)){
                AppUtils.showTipsTop("家长的手机一样也不可以为空哦!");
                return;
            }
            var reMobile=/^((1[3|4|5|7|8][0-9])|(0?0?(852|853)-?))\d{8}$/;
            if(!reMobile.test(vm.memberVo.memberPhone)) {
                AppUtils.showTipsTop("请输入正确的手机号哦!");
                return;
            }

            MemberModel.createParent(vm.memberVo).$promise.then(function(response){
                if(!AppUtils.isUndefinedOrNull(response) && response.stat === 'success'){
                    LoginAccountAuth.setAccount(response.loginAccountVo);
                    LoginAccountAuth.getAccount()
                        .then(function(data){
                            if(!AppUtils.isUndefinedOrNull(data.memberId)){
                                $location.path("/bind/createResult");
                            }
                        })
                }else if(response.stat === 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    AppUtils.showAlert("创建失败，请稍后再试！");
                }
            })

        }
    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider"];
    angular.module('App.pages.class', [
        'App.pages.class.msg'
    ])
        .config(routeConfig);

    function routeConfig($stateProvider) {

        $stateProvider.state('classMenu', {
            url: "/class",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('classMenu.studentIndex', {
            url: "/studentIndex/{studentId:string}",
            params: {
                studentId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/student/index.html',
                    controller:'StudentCtrl as vm',
                    resolve: {
                        studentId: ["$stateParams", function($stateParams){
                            return $stateParams.studentId;
                        }]
                    }
                }
            }
        }).state('classMenu.teacherIndex', {
            url: "/teacherIndex",
            cache: true,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/teacher/index.html',
                    controller:'TeacherCtrl as vm'
                }
            }
        }).state('classMenu.classInfo', {
            url: "/classInfo",
            cache: true,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/info/class-info.html',
                    controller:'ClassInfoCtrl as vm'
                }
            }
        }).state('classMenu.classNotice',{
            url: "/classNotice",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/notice/list.html',
                    controller:'ClassNoticeCtrl as vm'
                }
            }
        }).state('classMenu.noticeInfo',{
            url: "/noticeInfo/{noticeId:string}",
            params: {
                noticeId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/notice/index.html',
                    controller: 'ClassNoticeInfoCtrl as vm',
                    resolve: {
                        noticeId: ["$stateParams", function($stateParams){
                            return $stateParams.noticeId;
                        }],
                    }
                }
            }
        }).state('classMenu.classActivity',{
            url: "/classActivity",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/activity/list.html',
                    controller: 'ClassActivityCtrl as vm'
                }
            }
        }).state('classMenu.activityInfo',{
            url: "/activityInfo/{activityId:string}",
            params: {
                activityId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/activity/index.html',
                    controller: 'ClassActivityInfoCtrl as vm',
                    resolve: {
                        activityId: ["$stateParams", function($stateParams){
                            return $stateParams.activityId;
                        }],
                    }
                }
            }
        }).state('classMenu.teacherEntrustList', {
            url: "/teacherEntrustList",
            cache: true,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/entrust/teacher-entrust-list.html',
                    controller:'TeacherEntrustCtrl as vm'
                }
            }
        }).state('classMenu.teacherEntrustInfo', {
            url: "/teacherEntrustInfo/{entrustId:string}",
            cache: false,
            params: {
                entrustId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/entrust/teacher-entrust-info.html',
                    controller:'TeacherEntrustInfoCtrl as vm',
                    resolve: {
                        entrustId: ["$stateParams", function($stateParams){
                            return $stateParams.entrustId;
                        }]
                    }
                }
            }
        });
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    ClassModel.$inject = ["API", "$resource"];
    angular.module('App.pages.class')
        .service('ClassModel', ClassModel);

    function ClassModel(API,$resource) {

        this.actions = {}
        this.actions.findClassByName = {
            method: 'POST',
            url: API + '/class/findClassByName'
        }
        return $resource.call(this, this.actions)
    }

})();
/**
 * Created by hxpeng on 2017/5/11.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider"];
    angular.module('App.pages.common', [])
        .config(routeConfig);

    function routeConfig($stateProvider) {
        $stateProvider.state('common', {
            url: "/common",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('common.pageNotFound', {
            url: "/pageNotFound",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/common/pageNotFound.html'
                }
            }
        });
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider", "$urlRouterProvider"];
    angular.module('App.pages.dynamic', [])
        .config(routeConfig);

    function routeConfig($stateProvider,$urlRouterProvider) {
        $stateProvider.state('dynamic', {
            url: "/dynamic",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('dynamic.index', {
            url: "/index",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/dynamic/index.html',
                    controller:'DynamicCtrl as vm'
                }
            }
        }).state('dynamic.create', {
            url: "/create",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/dynamic/create.html',
                    controller:'DynamicCreateCtrl as vm'
                }
            }
        }).state('dynamic.info', {
            url: "/info?{dynamicId:string}",
            cache: false,
            params: {
                dynamicId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/dynamic/info.html',
                    controller:'DynamicInfoCtrl as vm'
                }
            }
        });
    }
})();
/**
 * Created by hxpeng on 2017/4/18.
 */
(function () {
    'use strict';

    DynamicCreateCtrl.$inject = ["$scope", "$state", "AppUtils", "DynamicModel", "$location", "$http", "Global", "LoginAccountAuth"];
    angular.module('App.pages.dynamic')
        .controller('DynamicCreateCtrl', DynamicCreateCtrl);

    function DynamicCreateCtrl($scope,$state,AppUtils,DynamicModel,$location,$http,Global,LoginAccountAuth) {
        $scope.$on('$ionicView.enter', function(){
            var currentPath = $location.url();
            if(currentPath.indexOf("#") != -1){
                currentPath = currentPath.split('#')[0];
            }
            currentPath = Global.path.wechat_path + currentPath;
            $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
                .success(function(data){
                    wx.config({
                        debug: false,
                        appId: data.appId,
                        timestamp: data.timestamp,
                        nonceStr: data.noncestr,
                        signature: data.signature,
                        jsApiList: ['chooseImage','previewImage','uploadImage']
                    });
                    wx.error(function(res){
                        console.log(res);
                    });
                })
                .error(function(data,header,config,status){
                    AppUtils.showAlert("请求微信sdk校验异常");
                });

        });

        var vm = this;
        vm.dynamic = {};
        vm.dynamic.content = '4月19日，习近平总书记来到广西壮族自治区考察调研。此前一天，外交部宣布了“一带一路”国际合作高峰论坛于5月在北京举行的消息。广西是“一带一路”交汇对接的重要门户，考察首站又定在汉代海上丝绸之路早期始发港——北海，其中深意不言自明。北海市位于广西北部湾畔，是国家历史文化名城。这里面向东南亚，背靠大西南，是西南出海大通道的重要出海口。“向海经济”“向海之路”，是习近平考察调研中反复提及的词汇。2000多年前，张骞出使西域，打通陆上丝绸之路。当时的合浦，就已经开辟通往印度、斯里兰卡的航线，成为走向东南亚、南亚的古代海上丝绸之路的重要始发港。';
        vm.imgIndex = 0;//imgUrl中保存的图片唯一标识符
        vm.imgUrl = [];//页面预览图片数组
        vm.postImgArray = [];//提交后台图片serverId数组
        $scope.localIds = "";
        vm.studentList = [];//家长绑定的孩子数字
        vm.chooseStudentList = [];//可看见动态的孩子班级
        vm.chooseStudentListTemp = [];


        LoginAccountAuth.getAccount().then(function(data){
            angular.forEach(data.studentVoList,function(obj){
                if(!AppUtils.isUndefinedOrNull(obj.classId)){
                    vm.studentList.push(obj);
                }
            })
        })


        $scope.chooseImg = function(){
            wx.chooseImage({
                count: 9,
                sizeType: ['original', 'compressed'],
                sourceType: ['album', 'camera'],
                success: function (res) {
                    var localIds = res.localIds;
                    syncPutImg(localIds);
                    AppUtils.loading();
                }
            });
        }

        //同步上传图片
        var syncPutImg = function(localIds){
            var img = localIds.pop();
            wx.uploadImage({
                localId: img,
                isShowProgressTips: 0,
                success: function (res) {
                    var serverId = res.serverId; // 返回图片的服务器端ID
                    var obj = {};
                    obj.imgIndex = vm.imgIndex;
                    obj.url = img;
                    obj.serverId = serverId;
                    $scope.$apply(function(){
                        vm.imgUrl.push(obj);
                    });
                    vm.imgIndex++;
                    if(localIds.length > 0){
                        syncPutImg(localIds);
                    }else{
                        //$scope.uploadImg();//选择完成后上传图片
                        AppUtils.loadfinish();
                    }
                }
            });
        };

        //大图片预览
        $scope.previewImg = function(url){
            var imgArray = [];
            angular.forEach(vm.imgUrl, function(obj, index) {
                imgArray.push(obj.url);
            });
            wx.previewImage({
                current: url,
                urls: imgArray
            });
        }

        //删除选择的图片
        $scope.removePicture = function(url,imgIndex){
            var urlIndex = null;
            angular.forEach(vm.imgUrl, function(obj, index) {
                if (obj.url === url && obj.imgIndex === imgIndex) {
                    urlIndex = index;
                }
            });
            $scope.$apply(function(){
                vm.imgUrl.splice(urlIndex, 1);
            });
        }

        //页面初始化绑定事件
        $("#choose-child-btn,.entrust-create-screen").on("click",function(){
            $(".container").toggleClass('toggled');
        })
        $(".entrust-create-screen").on("click",".card-facebook",function(e){
            $(this).toggleClass('toggled');
            e.stopPropagation();
        })
        $scope.removeStudent = function(index){
            vm.chooseStudentList.splice(index, 1);
        }


        $("#choose-student-btn").on("click",function(e){
            var keepGoing = true;
            var studentList = $(".entrust-create-screen").find(".card-facebook.toggled");
            studentList.each(function(){
                var id = $(this).attr("data-studentId");
                angular.forEach(vm.chooseStudentListTemp,function(data){
                    if(data.id === id){
                        keepGoing = false;
                        return;
                    }
                })
                if(keepGoing){
                    var obj = {};
                    obj.studentId = id;
                    obj.classId = $(this).attr("data-classId");
                    obj.studentName = $(this).attr("data-studentName");
                    obj.studentAvatarPath = $(this).attr("data-studentAvatarPath");
                    vm.chooseStudentListTemp.push(obj);
                }
                $(this).removeClass("toggled");
            })
            $scope.$apply(function () {
                var obj = [];
                var addToArray=true;
                angular.forEach(vm.chooseStudentListTemp,function(a){
                    angular.forEach(vm.chooseStudentList,function(b){
                        if(b.studentId === a.studentId){
                            addToArray=false;
                            return;
                        }
                    })
                    if(addToArray){
                        vm.chooseStudentList.push(a);
                    }
                    addToArray=true;
                })
                vm.chooseStudentListTemp = [];
            });
        })


        //取动态正文和图文 填充进div，保存div的html值
        $scope.prepareDynamic = function(){
            vm.dynamic.thumbnail = "";
            var resultHtml = angular.element("#resultHtml");
            resultHtml.append("<p>"+vm.dynamic.content+"</p>");

            if(!AppUtils.isUndefinedOrNull(vm.imgUrl)){
                angular.forEach(vm.imgUrl, function(obj, index) {
                    if (!AppUtils.isUndefinedOrNull(obj.serverId)) {
                        vm.postImgArray.push(obj.serverId);
                    }
                });
                DynamicModel.submitUploadImg({serverIds: JSON.stringify(vm.postImgArray)}).$promise.then(function(response){
                    if(response.stat == 'success'){
                        //后台下载图片成功返回的文件集合
                        var fileList = response.fileList;
                        var imgBoxList = angular.element(".img-box");
                        var keepGoing;
                        var thumbnailLen = 3;
                        angular.forEach(fileList,function(obj){
                            keepGoing = true;
                            if(thumbnailLen > 0){
                                vm.dynamic.thumbnail += obj.thumbnail + ";";
                            }
                            angular.forEach(imgBoxList,function(box){
                                if(keepGoing){
                                    var img = angular.element(box).find("img")[0];
                                    if(!AppUtils.isUndefinedOrNull(img) && img.attributes['name'].value == obj.mediaId){
                                        var textarea = angular.element(box).find("textarea")[0];
                                        resultHtml.append("<div>");
                                        resultHtml.append("<img src='"+obj.filePath+"' style='width: 100%;'>");
                                        resultHtml.append("<br/>" + textarea.value);
                                        resultHtml.append("</div>");
                                        keepGoing = false;
                                    }
                                }
                            })
                            thumbnailLen--;
                        })
                        $scope.commit();
                    }else if(response.stat == 'err'){
                        AppUtils.showAlert("图片上传失败失败:" + response.msg);
                        return false;
                    }
                });
            }else{
                $scope.commit();
            }
            console.log(resultHtml.html());
        }


        $scope.commit = function(){
            var obj = {};
            var classIds = [];

            angular.forEach(vm.chooseStudentList,function(data){
                classIds.push(data.classId);
            })
            if(classIds.length < 1){
                AppUtils.showTipsTop("请选择班级");
                return;
            }

            obj.classIds = _.clone(classIds);
            obj.title = vm.dynamic.title;
            obj.content = angular.element("#resultHtml").html();
            vm.dynamic.thumbnail = vm.dynamic.thumbnail.substring(0, vm.dynamic.thumbnail.length - 1)
            obj.thumbnail = vm.dynamic.thumbnail;
            DynamicModel.saveDynamic(obj).$promise.then(function(response){
                if(response.stat == 'success'){
                    $state.go("dynamic.index");
                }else{
                    AppUtils.showAlert("发布动态失败：" + response.msg + ",稍后再试试吧！");
                }
            })
        }


    }

})();

/**
 * Created by hxpeng on 2017/4/18.
 */
(function () {
    'use strict';

    DynamicCtrl.$inject = ["$scope", "DynamicModel", "$location", "LoginAccountAuth", "$timeout"];
    angular.module('App.pages.dynamic')
        .controller('DynamicCtrl', DynamicCtrl);

    function DynamicCtrl($scope,DynamicModel,$location,LoginAccountAuth,$timeout) {

        //效果事件
        //页面进入先绑定事件，（即使是缓存页面也会执行）
        $scope.$on('$ionicView.enter', function(){
            $('a.target-burger').unbind("click").bind("click",function(e){
                if(!$('nav.main-nav').hasClass('toggled')){
                    var timer1 = $timeout(
                        function() {
                            $('#btn1').toggleClass('toggled');
                        },
                        0
                    );
                    var timer2 = $timeout(
                        function() {
                            $('#btn2').toggleClass('toggled');
                        },
                        50
                    );
                    var timer3 = $timeout(
                        function() {
                            $('#btn3').toggleClass('toggled');
                        },
                        100
                    );
                    $('nav.main-nav, a.target-burger').addClass('toggled');
                }else{
                    var timer1 = $timeout(
                        function() {
                            $('#btn3').removeClass('toggled');
                            $('#btn2').removeClass('toggled');
                            $('#btn1').removeClass('toggled');
                        },
                        100
                    );
                    timer1.then(
                        function() {
                            $('nav.main-nav, a.target-burger').removeClass('toggled');
                        }
                    );
                }

                e.preventDefault();
            })
        });

        $scope.$on('$ionicView.beforeLeave', function(){
            if($(".main-nav").hasClass('toggled')){
                $('a.target-burger').click();
            }
        });

        $scope.createNewDynamic = function(){
            $location.path('/dynamic/create');
        }


        //逻辑代码
        var vm = this;
        vm.loginAccountVo = {};
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 1;//第一页



        LoginAccountAuth.getAccount()
            .then(function(data){
                vm.loginAccountVo = data;
                vm.getDynamic();
            })


        vm.getDynamic = function(){
            DynamicModel.dynamicList({
                pageInfo: {
                    pageSize: 5,
                    pageNumber: vm.pageIndex
                }
            }).$promise.then(function(response){
                var reponseDate = response.pageResult;
                var items = reponseDate.pageResult;
                var pageIndex = reponseDate.pageIndex;
                var pageTotalPageSize = reponseDate.pageTotalPageSize;
                if(pageIndex == pageTotalPageSize || items.length == 0){
                    vm.loadMoreBtnStatus = false;
                    vm.loadMoreBtnStr = "没有更多数据了";
                }
                angular.forEach(items,function(data){
                    vm.exhortaions.push(data);
                })
            })
        }

    }

})();

/**
 * Created by hxpeng on 2017/4/18.
 */
(function () {
    'use strict';

    DynamicInfoCtrl.$inject = ["$scope", "DynamicModel", "$stateParams", "AppUtils"];
    angular.module('App.pages.dynamic')
        .controller('DynamicInfoCtrl', DynamicInfoCtrl);

    function DynamicInfoCtrl($scope,DynamicModel,$stateParams,AppUtils) {

        var vm = this;
        vm.dynamic = {};
        vm.dynamicId = "";
        $scope.$on('$ionicView.enter', function(){
            vm.dynamicId = _.clone($stateParams.dynamicId);
            if(!AppUtils.isUndefinedOrNull(vm.dynamicId)){
                DynamicModel.getDynamicInfo({id:vm.dynamicId}).$promise.then(function(response){
                    if(response.stat == 'success'){
                        vm.dynamic = _.clone(response.dynamicInfo);
                    }
                })
            }
        });
    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    DynamicModel.$inject = ["API", "$resource"];
    angular.module('App.pages.dynamic')
        .service('DynamicModel', DynamicModel);

    function DynamicModel(API,$resource) {
        this.actions = {}

        this.actions.dynamicList = {
            method: 'POST',
            url: API + '/dynamic/dynamicList'
        }

        this.actions.saveDynamic = {
            method: 'POST',
            url: API + '/dynamic/saveDynamic'
        }

        this.actions.submitUploadImg = {
            method: 'POST',
            url: API + '/dynamic/submitUploadImg'
        }

        this.actions.getDynamicInfo = {
            method: 'POST',
            url: API + '/dynamic/getDynamicInfo'
        }

        return $resource.call(this, this.url, this.params, this.actions)
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider"];
    angular.module('App.pages.member', [
        'App.pages.member.entrust'
    ]).config(routeConfig);

    function routeConfig($stateProvider) {
        $stateProvider.state('memberMenu', {
            url: "/member",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('memberMenu.addStudent', {
            url: "/addStudent",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/student/addStudent.html',
                    controller:'AddStudentCtrl as vm'
                }
            }
        }).state('memberMenu.parentIndex', {
            url: "/parentIndex",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/parent/index.html',
                    controller:'ParentCtrl as vm'
                }
            }
        }).state('memberMenu.parentInfo', {
            url: "/parentInfo/{studentId:string}",
            params: {
                studentId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/parent/parent-info.html',
                    controller:'ParentInfoCtrl as vm',
                    resolve: {
                        studentId: ["$stateParams", function($stateParams){
                            return $stateParams.studentId;
                        }]
                    }
                }
            }
        }).state('memberMenu.albumIndex', {
            url: "/albumIndex",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/album/album-index.html',
                    controller:'AlbumCtrl as vm'
                }
            }
        }).state('memberMenu.albumCreate', {
            url: "/albumCreate",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/album/add-album.html',
                    controller:'AddAlbumCtrl as vm'
                }
            }
        }).state('memberMenu.chooseStudent', {
            url: "/chooseStudent?{nextState:string}",
            params: {
                nextState: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/student/chooseStudent.html',
                    controller:'ChooseStudentCtrl as vm'
                }
            }
        }).state('memberMenu.edit', {
            url: "/edit",
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/info/member-edit.html',
                    controller:'MemberEditCtrl as vm'
                }
            }
        });
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    MemberModel.$inject = ["API", "$resource"];
    angular.module('App.pages.member')
        .service('MemberModel', MemberModel);

    function MemberModel(API,$resource) {
        this.actions = {}


        /**
         * 绑定微信号并创建一个家长成员
         * @type {{method: string, url: string}}
         */
        this.actions.createParent = {
            method: 'post',
            url: API + '/wechat/member/createParent'
        }
        /**
         * 家长绑定/添加 宝宝
         * @type {{method: string, url: string}}
         */
        this.actions.studentBindParent = {
            method: 'post',
            url: API + '/wechat/member/studentBindParent'
        }

        /**
         *  根据成员ID，查询一个成员
         * @type {{method: string, url: string}}
         */
        this.actions.getMemberInfo = {
            method: 'post',
            url: API + '/member/getMemberInfo'
        }


        this.actions.findOneStudent = {
            method: 'post',
            url: API + '/member/findOneStudent'
        }

        /**
         * 和微信号绑定
         * @type {{method: string, url: string}}
         */
        this.actions.bindWeChatInfo = {
            method: 'POST',
            url: API + '/member/bindWeChatInfo'
        }
        /**
         * 获取父母成员信息
         * @type {{method: string, url: string}}
         */
        this.actions.getParentInfo = {
            method: 'POST',
            url: API + '/member/getParentInfo'
        }
        /**
         * 保存成员信息
         * @type {{method: string, url: string}}
         */
        this.actions.saveParentMemberInfo = {
            method: 'POST',
            url: API + '/member/saveParentMemberInfo'
        }

        /**
         *提交微信返回上传图片的serverId数组
         * @type {{method: string, url: string}}
         */
        this.actions.submitUploadImg = {
            method: 'POST',
            url: API + '/member/submitUploadImg'
        }

        /**
         * 精彩瞬间
         * @type {{method: string, url: string}}
         */
        this.actions.queryStudentsPhoto = {
            method: 'POST',
            url: API + '/member/queryStudentsPhoto'
        }

        /**
         * 查找学生列表
         * @type {{method: string, url: string}}
         */
        this.actions.getStudentList = {
            method: 'POST',
            url: API + '/class/getStudentList'
        }

        /**
         * 返回父母成员ID
         * @type {{method: string, url: string}}
         */
        this.actions.getParentId = {
            method: 'POST',
            url: API + '/member/getParentId'
        }

        this.actions.studentHadBind = {
            method: 'POST',
            url: API + '/member/studentHadBind'
        }






        return $resource.call(this, this.url, this.params, this.actions)
    }

})();
angular.module('app', ['ionic'])

    .config(["$stateProvider", "$urlRouterProvider", function($stateProvider, $urlRouterProvider){
        'use strict';
        $stateProvider
            .state('app', {
                url: '/app',
                templateUrl: 'views/app.html',
                controller: 'AppCtrl'
            });
        $urlRouterProvider.otherwise('/app');
    }])

    .run(["$ionicPlatform", function($ionicPlatform) {
        'use strict';
        $ionicPlatform.ready(function() {
            if(window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            }
            if(window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    }])

    .factory('TwittSrv', ["$q", "$timeout", function($q, $timeout){
        'use strict';
        var twitts = [
            {user: {id: '凤舞九天', name: '1、吴明', avatar: 'https://pbs.twimg.com/profile_images/459365829348302849/lJ1X8rU9_bigger.png'}, content: '江湖绰号“小老头”。《凤舞九天》第一高手，无名岛岛主。实力相当于3个绝顶高手。', url: 'https://twitter.com/Ionicframework/status/569962126556708864'},
            {user: {id: '画眉鸟', name: '2、阴姬', avatar: 'https://pbs.twimg.com/profile_images/554941644579954688/xxp8o3Cq_bigger.png'}, content: '人称“水母”。《画眉鸟》第一高手，神水宫主人。实力相当于2.5个绝顶高手。', url: 'https://twitter.com/IonicBE/status/569787372650385408'},
            {user: {id: '绝代双娇', name: '3、燕南天', avatar: 'https://pbs.twimg.com/profile_images/539837685481762816/cOO1F28S_bigger.png'}, content: '《绝代双娇》第一高手，当世江湖第一神剑。实力相当于2个绝顶高手。', url: 'https://twitter.com/forum_hc/status/568806047051165696'},
            {user: {id: '大沙漠', name: '4、李商', avatar: 'https://pbs.twimg.com/profile_images/3133057797/81ea4e63c7078eec0a7c7d6ae57a3ce1_bigger.jpeg'}, content: '人称“石观音”，《大沙漠》第一高手，50招胜楚留香。实力相当于2个绝顶高手。', url: 'https://twitter.com/loicknuchel/status/568449174926176256'},
            {user: {id: '武林外史', name: '5、柴玉关', avatar: 'https://pbs.twimg.com/profile_images/378800000568876933/2da22327d055cbf8e0502c3f22888fef_bigger.jpeg'}, content: '人称“快活王”，《武林外史》第一高手。实力相当于2个绝顶高手。', url: 'https://twitter.com/raymondcamden/status/568424487693082625'},
            {user: {id: '幽灵山庄', name: '6、木道人', avatar: 'https://pbs.twimg.com/profile_images/2653730816/5da4d8fb72352c715bbaffe07e56270e_bigger.jpeg'}, content: '江湖人称“老刀把子”，武当第一名宿，《幽灵山庄》第一高手。实力相当于2个绝高手。', url: 'https://twitter.com/nraboy/status/568438200198258689'},
            {user: {id: '绝代双娇', name: '7、邀月宫主', avatar: 'https://pbs.twimg.com/profile_images/378800000664886768/5aa49c1cded0317a887cae28f5d80cd7_bigger.jpeg'}, content: '人称“绣玉谷”，移花宫的大宫主。实力相当于2个绝顶高手。', url: 'https://twitter.com/devgirlFL/status/563673910424928256'},
            {user: {id: '陆小凤传奇', name: '8、西门吹雪', avatar: 'https://pbs.twimg.com/profile_images/546942133496995840/k7JAxvgq_bigger.jpeg'}, content: '“万梅山庄”庄主，江湖第一剑神。实力相当于1.5个绝顶高手。', url: 'https://twitter.com/maxlynch/status/568097163131006976'},
            {user: {id: '剑客行', name: '9、展白', avatar: 'https://pbs.twimg.com/profile_images/519532575031713792/Fm4zj2Zm_bigger.jpeg'}, content: '《剑客行》第一高手，全书第一主人公。实力相当于1.5个绝顶高手。', url: 'https://twitter.com/asdvaughan/status/566103487281635328'},
            {user: {id: '名剑风流', name: '10、俞佩玉', avatar: 'https://pbs.twimg.com/profile_images/378800000664886768/5aa49c1cded0317a887cae28f5d80cd7_bigger.jpeg'}, content: '《名剑风流》第一高手，全书第一主人公。实力相当于1.5个绝顶高手。', url: 'https://twitter.com/devgirlFL/status/563673910424928256'},
        ];

        var service = {
            getTwitts: getTwitts,
            getNewTwitts: getNewTwitts,
            getMoreTwitts: getMoreTwitts
        };

        function getTwitts(){
            return $q.when(angular.copy(twitts));
        }

        function getNewTwitts(){
            var defer = $q.defer();
            $timeout(function(){
                var newTwitt = angular.copy(twitts[Math.floor(Math.random()*twitts.length)]);
                defer.resolve([newTwitt]);
            }, 500);
            return defer.promise;
        }

        function getMoreTwitts(){
            var defer = $q.defer();
            $timeout(function(){
                var newTwitts = [];
                for(var i=0; i<5; i++){
                    newTwitts.push(angular.copy(twitts[Math.floor(Math.random()*twitts.length)]));
                }
                defer.resolve(newTwitts);
            }, 500);
            return defer.promise;
        }

        return service;
    }])

    .controller('AppCtrl', ["$scope", "TwittSrv", function($scope, TwittSrv){
        'use strict';
        TwittSrv.getTwitts().then(function(twitts){
            $scope.twitts =twitts ;
        });

        $scope.doRefresh = function(){
            TwittSrv.getNewTwitts().then(function(newTwitts){
                $scope.twitts = newTwitts.concat($scope.twitts);
            }).finally(function() {
                // Stop the ion-refresher from spinning
                $scope.$broadcast('scroll.refreshComplete');
            });
        };

        $scope.loadMore = function(){
            TwittSrv.getMoreTwitts().then(function(olderTwitts){
                $scope.twitts = $scope.twitts.concat(olderTwitts);
            }).finally(function() {
                // Stop the ion-infinite-scroll from spinning
                $scope.$broadcast('scroll.infiniteScrollComplete');
            });
        };
    }]);

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('dynamicUploadPic', dynamicUploadPic);

    /**
     * 发表动态上传图片，添加图片div和描述div
     * @returns {{restrict: string, link: link}}
     */
    function dynamicUploadPic() {
        return {
            restrict:'E',
            replace :true,
            template:'<div class="img-box" ng-hide="myCheck"><img>' +
            '<button class="button button-icon ion-close-circled item-body-remove-btn"></button><br/><textarea style="width: 100%;padding: 5px;" placeholder="输入照片描述...." rows="2" ng-trim="false" maxlength="2000"></textarea></div>',
            link: function(scope, elem, attr) {
                scope.$watch('per',function(nowVal){
                    var img = nowVal;
                    var elem_child = elem[0].childNodes;
                    angular.forEach(elem_child,function(obj){
                        if(obj.nodeName == "IMG"){
                            obj.setAttribute('src',img.url);
                            obj.setAttribute('name',img.serverId);
                            obj.onclick=function(){
                                scope.previewImg(img.url);
                            }
                        }
                        if(obj.nodeName == "BUTTON"){
                            obj.onclick=function(){
                                scope.removePicture(img.url,img.imgIndex);
                            }
                        }

                    })
                    autosize(document.querySelectorAll('textarea'));
                })

            }
        };
    }

})();
/**
 * 文字溢出，查看更多---插件
 */

(function() {
    'use strict';
    angular.module( 'ngTextTruncate', [] )
        .directive( "ngTextTruncate", [ "$compile", "ValidationServices", "CharBasedTruncation", "WordBasedTruncation",
            function( $compile, ValidationServices, CharBasedTruncation, WordBasedTruncation ) {
                return {
                    restrict: "A",
                    scope: {
                        text: "=ngTextTruncate",
                        charsThreshould: "@ngTtCharsThreshold",
                        wordsThreshould: "@ngTtWordsThreshold",
                        customMoreLabel: "@ngTtMoreLabel",
                        customLessLabel: "@ngTtLessLabel"
                    },
                    controller: ["$scope", "$element", "$attrs", function( $scope, $element, $attrs ) {
                        $scope.toggleShow = function() {
                            $scope.open = !$scope.open;
                        };

                        $scope.useToggling = $attrs.ngTtNoToggling === undefined;
                    }],
                    link: function( $scope, $element, $attrs ) {
                        $scope.open = false;

                        ValidationServices.failIfWrongThreshouldConfig( $scope.charsThreshould, $scope.wordsThreshould );

                        var CHARS_THRESHOLD = parseInt( $scope.charsThreshould );
                        var WORDS_THRESHOLD = parseInt( $scope.wordsThreshould );

                        $scope.$watch( "text", function() {
                            $element.empty();

                            if( CHARS_THRESHOLD ) {
                                if( $scope.text && CharBasedTruncation.truncationApplies( $scope, CHARS_THRESHOLD ) ) {
                                    CharBasedTruncation.applyTruncation( CHARS_THRESHOLD, $scope, $element );

                                } else {
                                    $element.append( $scope.text );
                                }

                            } else {

                                if( $scope.text && WordBasedTruncation.truncationApplies( $scope, WORDS_THRESHOLD ) ) {
                                    WordBasedTruncation.applyTruncation( WORDS_THRESHOLD, $scope, $element );

                                } else {
                                    $element.append( $scope.text );
                                }

                            }
                        } );
                    }
                };
            }] )



        .factory( "ValidationServices", function() {
            return {
                failIfWrongThreshouldConfig: function( firstThreshould, secondThreshould ) {
                    if( (! firstThreshould && ! secondThreshould) || (firstThreshould && secondThreshould) ) {
                        throw "You must specify one, and only one, type of threshould (chars or words)";
                    }
                }
            };
        })



        .factory( "CharBasedTruncation", [ "$compile", function( $compile ) {
            return {
                truncationApplies: function( $scope, threshould ) {
                    return $scope.text.length > threshould;
                },

                applyTruncation: function( threshould, $scope, $element ) {
                    if( $scope.useToggling ) {
                        var el = angular.element(    "<span>" +
                            $scope.text.substr( 0, threshould ) +
                            "<span ng-show='!open'>...</span>" +
                            "<span class='btn-link ngTruncateToggleText' " +
                            "ng-click='toggleShow()'" +
                            "ng-show='!open'>" +
                            " " + ($scope.customMoreLabel ? $scope.customMoreLabel : "More") +
                            "</span>" +
                            "<span ng-show='open'>" +
                            $scope.text.substring( threshould ) +
                            "<span class='btn-link ngTruncateToggleText'" +
                            "ng-click='toggleShow()'>" +
                            " " + ($scope.customLessLabel ? $scope.customLessLabel : "Less") +
                            "</span>" +
                            "</span>" +
                            "</span>" );
                        $compile( el )( $scope );
                        $element.append( el );

                    } else {
                        $element.append( $scope.text.substr( 0, threshould ) + "..." );

                    }
                }
            };
        }])



        .factory( "WordBasedTruncation", [ "$compile", function( $compile ) {
            return {
                truncationApplies: function( $scope, threshould ) {
                    return $scope.text.split( " " ).length > threshould;
                },

                applyTruncation: function( threshould, $scope, $element ) {
                    var splitText = $scope.text.split( " " );
                    if( $scope.useToggling ) {
                        var el = angular.element(    "<span>" +
                            splitText.slice( 0, threshould ).join( " " ) + " " +
                            "<span ng-show='!open'>...</span>" +
                            "<span class='btn-link ngTruncateToggleText' " +
                            "ng-click='toggleShow()'" +
                            "ng-show='!open'>" +
                            " " + ($scope.customMoreLabel ? $scope.customMoreLabel : "More") +
                            "</span>" +
                            "<span ng-show='open'>" +
                            splitText.slice( threshould, splitText.length ).join( " " ) +
                            "<span class='btn-link ngTruncateToggleText'" +
                            "ng-click='toggleShow()'>" +
                            " " + ($scope.customLessLabel ? $scope.customLessLabel : "Less") +
                            "</span>" +
                            "</span>" +
                            "</span>" );
                        $compile( el )( $scope );
                        $element.append( el );

                    } else {
                        $element.append( splitText.slice( 0, threshould ).join( " " ) + "..." );
                    }
                }
            };
        }]);

}());
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('ngFileSelect', ngFileSelect);

    /**
     * input file 选择文件触发
     * @returns {{link: link}}
     */
    function ngFileSelect() {
        return {
            link: function($scope,el){
                el.bind("change", function(e){
                    $scope.file = (e.srcElement || e.target).files[0];
                    $scope.getFile();
                })
            }
        }
    }

})();
/**
 * Created by hxpeng on 2017/5/3.
 */

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('photoPrevire', photoPrevire);

    /**
     * 精彩瞬间选择图片之后预览，
     * @returns {{restrict: string, link: link}}
     */
    function photoPrevire() {
        return {
            restrict:'E',
            replace :true,
            template:'<li><img class="full-image"></li>',
            link: function(scope, elem, attr) {
                scope.$watch('per',function(nowVal){
                    var img = {};
                    var previewStat = false;
                    if(typeof nowVal == 'string'){
                        img.url = nowVal;
                    }else if(typeof nowVal == 'object'){
                        img = nowVal;
                        previewStat = true;
                    }

                    var elem_child = elem[0].childNodes;
                    angular.forEach(elem_child,function(obj){
                        if(obj.nodeName == "IMG"){
                            obj.setAttribute('src',img.url);
                            if(previewStat){
                                obj.onclick=function(){
                                    scope.previewImg(img.url,img.key);
                                }
                            }
                        }
                    })
                })

            }
        };
    }

})();
/**
 * Created by hxpeng on 2017/4/7.
 * input為number类型时，需要自定义一个指令来格式化
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('stringToNumber', stringToNumber);

    /** @ngInject */
    function stringToNumber() {
        return {
            require: 'ngModel',
            link: function(scope, element, attrs, ngModel) {
                ngModel.$parsers.push(function(value) {
                    return '' + value;
                });
                ngModel.$formatters.push(function(value) {
                    return parseFloat(value);
                });
            }
        };
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('textarea', textarea);


    /**
     * textarea 高度自适应
     * @returns {{restrict: string, link: link}}
     */
    function textarea() {
        return {
            restrict: 'E',
            link: function(scope, element, attr){
                var update = function(){
                    element.css("height", "auto");
                    var height = element[0].scrollHeight;
                    element.css("height", element[0].scrollHeight + "px");
                };
                scope.$watch(attr.ngModel, function(){
                    update();
                });
            }
        };
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('wxImg', wxImg);


    /**
     * 微信选择图片之后预览，并绑定删除图片
     * @returns {{restrict: string, link: link}}
     */
    function wxImg() {
        return {
            restrict:'E',
            replace :true,
            template:'<li><img class="full-image"><i class="ion-close-circled removeImgBtn"></i></li>',
            link: function(scope, elem, attr) {
                scope.$watch('per',function(nowVal){
                    var img = nowVal;
                    var elem_child = elem[0].childNodes;
                    angular.forEach(elem_child,function(obj){
                        if(obj.nodeName == "IMG"){
                            obj.setAttribute('src',img.url);
                            obj.onclick=function(){
                                scope.previewImg(img.url);
                            }
                        }
                        if(obj.nodeName == "I"){
                            obj.onclick=function(){
                                scope.removePicture(img.url,img.imgIndex);
                            }
                        }

                    })
                })

            }
        };
    }

})();
/**
 * Created by hxpeng on 2017/5/02.
 */
(function () {
    'use strict';

    angular.module('App.common')
        .filter('ageFilter', ageFilter);

    /**
     * 生日日期转年龄
     * @returns {Function}
     */
    function ageFilter() {
        function calculateAge(birthday) { // birthday is a date
            birthday = new Date(birthday);
            var ageDifMs = Date.now() - birthday.getTime();
            var ageDate = new Date(ageDifMs); // miliseconds from epoch
            return Math.abs(ageDate.getUTCFullYear() - 1970 + 1);
        }
        return function(birthdate) {
            return calculateAge(birthdate);
        };
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';
    ApiCodeInterceptorConfiguration.$inject = ["$httpProvider"];
    angular.module('App.common')
        .config(ApiCodeInterceptorConfiguration);
    function ApiCodeInterceptorConfiguration($httpProvider) {

        ApiCodeInterceptor.$inject = ["$window", "$injector", "$q"];
        function ApiCodeInterceptor($window, $injector,$q) {
            return {
                request: function(config){
                    $injector.get('AppUtils').loading();
                    config.headers.auth_token = '1111';//设置请求头
                    return config;
                },
                requestError: function(err){
                    $injector.get('AppUtils').loadfinish();
                    //$injector.get('AppUtils').loadfinish();
                    return $q.reject(err);
                },
                response: function(res){
                    $injector.get('AppUtils').loadfinish();
                    return $q.resolve(res);
                },
                responseError: function(err){
                    var $AppUtils = $injector.get('AppUtils');
                    $AppUtils.loadfinish();
                    if(-1 === err.status) {
                        $AppUtils.showAlert("远程服务器无响应!");
                    } else if(404 === err.status) {
                        $AppUtils.showAlert("颯，找不到资源。。。。");
                    } else if(401 === err.status) {
                        console.log(err);
                        if(!$AppUtils.isUndefinedOrNull(err.data)){
                            console.log("跳转页面到：" + err.data);
                            $window.location.href = err.data;
                            return false;
                            //event.preventDefault();
                            //console.log(1111111111111111);
                        }
                    } else if(400 === err.status) {
                        $AppUtils.showAlert("非法提交！");
                    } else {
                        $AppUtils.showAlert("发生错误,代码：" + err.status);
                    }
                    return $q.reject(err);
                }
            }
        }
        $httpProvider.interceptors.push(ApiCodeInterceptor)
    }
})();
/**
 * Created by hxpeng on 2017/3/25.
 */
(function () {
    'use strict';

    authRun.$inject = ["$rootScope", "$state", "Global", "AppUtils", "$location", "LoginAccountAuth", "$window", "$timeout"];
    cordova.$inject = ["$ionicPlatform"];
    angular.module('App')
        .run(authRun)
        .run(cordova);

    //前端全局拦截登录
    function authRun($rootScope,$state,Global,AppUtils,$location,LoginAccountAuth,$window,$timeout) {

        $rootScope.$on('$ionicView.beforeEnter', function(){
            $("#loading").css("display","block");

        });

        $rootScope.$on('$ionicView.afterEnter', function(){
            $("#loading").fadeOut();
        });



        $rootScope.$on('$locationChangeStart', function (event, next, current) {
            var url  = $location.path();
            console.log(url);
            var postfix = -1;
            var pathStr;
            //路径?和#不能共存
            if(url.indexOf('?') != -1){
                postfix = url.indexOf('?');
            }
            if(url.indexOf('#') != -1){
                postfix = url.indexOf('#');
            }
            if(postfix != -1){
                pathStr = url.substr(0, postfix);
            }else{
                pathStr = url;
            }
            var keepGoing = true;
            //判断路径是否被拦截
            angular.forEach(Global.filterPath,function(data){
                if(pathStr == data){
                    keepGoing = false;
                    return;
                }
            })
            if(keepGoing){
                if(!LoginAccountAuth.isLoginIn()){
                    $location.replace();
                    var gotoUrl = LoginAccountAuth.getLastGotoUrl();
                    if(AppUtils.isUndefinedOrNull(gotoUrl) && AppUtils.isUndefinedOrNull(gotoUrl) && url != '/'){
                        LoginAccountAuth.setLastGotoUrl(url);
                        gotoUrl = url;
                    }
                    LoginAccountAuth.getAccount()
                        .then(function (data) {
                            var nextPath;
                            if(AppUtils.isUndefinedOrNull(data.memberId)){
                                nextPath = "/bind/menu";
                            }else{
                                if(!AppUtils.isUndefinedOrNull(gotoUrl) && gotoUrl != "/"){
                                    nextPath = gotoUrl;
                                    LoginAccountAuth.setLastGotoUrl(null);
                                    //加个参数解决angular不会重新请求。。。
                                    $location.path(nextPath).search({a: "111"});
                                    event.preventDefault();
                                }else{
                                    if(data.memberType == 2){
                                        nextPath = "/member/parentIndex";
                                    }else if(data.memberType == 1){
                                        nextPath = "/class/teacherIndex";
                                    }
                                }
                            }
                            $location.path(nextPath);
                        });
                    event.preventDefault();
                }else{
                    if(url === "/"){
                        LoginAccountAuth.getAccount()
                            .then(function (data) {
                                if(data.memberType == 2){
                                    $location.path("member/parentIndex");
                                }else if(data.memberType == 1){
                                    $location.path("class/teacherIndex");
                                }
                            });
                        event.preventDefault();
                    }
                }
            }
        });


        //监听路由变化之前
        $rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState,fromParams) {
            //layer.closeAll();
        })

        //监听路由变化成功
        $rootScope.$on('$stateChangeSuccess',function(event,toState,toParams,fromState,fromParams){
        });

        //监听路由未找到
        $rootScope.$on('$stateNotFound',function(event,toState,toParams,fromState,fromParams){
        });
    }

    function cordova($ionicPlatform){
        $ionicPlatform.ready(function() {
            // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
            // for form inputs)
            if(window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            }
            if(window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    }



})( );
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    AppUtils.$inject = ["$ionicPopup", "$ionicLoading", "$ionicScrollDelegate", "$window"];
    angular.module('App.common')
        .service('AppUtils', AppUtils);

    /**
     * 常用逻辑方法
     */
    function AppUtils($ionicPopup,$ionicLoading,$ionicScrollDelegate,$window) {

        return {
            isUndefinedOrNull: function(obj) {
                if(angular.isArray(obj)){
                    return obj==null||obj.length==0 ? true : false;
                }
                return !angular.isDefined(obj) || obj===null || obj=='';
            },
            showAlert: function(msg){
                $ionicPopup.alert({
                    title: '提示',
                    template: msg
                });
            },
            showConfirm: function(msg){
                var confirmPopup = $ionicPopup.confirm({
                    title: '提示',
                    template: msg
                });
                return confirmPopup;
            },
            loading: function(){
                $ionicLoading.show({
                    content: 'Loading',
                    animation: 'fade-in',
                    showBackdrop: true,
                    maxWidth: 200,
                    showDelay: 0
                });
            },
            loadfinish: function(){
                $ionicLoading.hide();
            },
            scrollTop: function(){
                $ionicScrollDelegate.scrollTop();
            },
            goBack: function(){
                $window.history.go(-1);
            },
            showTipsTop: function(msg){
                layer.open({
                    content: msg,
                    //anim: 'top',
                    skin: 'top',
                    time: 1000
                });
            },
            getClientType: function(){
                var userAgent = navigator.userAgent || navigator.vendor || window.opera;
                // Windows Phone must come first because its UA also contains "Android"
                if (/windows phone/i.test(userAgent)) {
                    return "wp";
                }
                if (/android/i.test(userAgent)) {
                    return "android";
                }
                // iOS detection from: http://stackoverflow.com/a/9039885/177710
                if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
                    return "ios";
                }
                return "unknown";
            }
        }
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    fileReader.$inject = ["$q"];
    angular.module('App.common')
        .service('fileReader', fileReader);

    /**
     * 文件read帮助
     */
    function fileReader($q){
        var onLoad = function(reader, deferred, scope) {
            return function () {
                scope.$apply(function () {
                    deferred.resolve(reader.result);
                });
            };
        };

        var onError = function (reader, deferred, scope) {
            return function () {
                scope.$apply(function () {
                    deferred.reject(reader.result);
                });
            };
        };

        var onProgress = function(reader, scope) {
            return function (event) {
                scope.$broadcast("fileProgress",
                    {
                        total: event.total,
                        loaded: event.loaded
                    });
            };
        };

        var getReader = function(deferred, scope) {
            var reader = new FileReader();
            reader.onload = onLoad(reader, deferred, scope);
            reader.onerror = onError(reader, deferred, scope);
            reader.onprogress = onProgress(reader, scope);
            return reader;
        };

        var readAsDataURL = function (file, scope) {
            var deferred = $q.defer();

            var reader = getReader(deferred, scope);
            reader.readAsDataURL(file);

            return deferred.promise;
        };

        return {
            readAsDataUrl: readAsDataURL
        };
    }
})();


/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    LocalStorageUtils.$inject = ["$window"];
    angular.module('App.common')
        .service("LocalStorageUtils",LocalStorageUtils)

    /**
     * 浏览器本地存储工具js
     * @param $window
     * @returns {{set: set, get: get, setObject: setObject, getObject: getObject}}
     * @constructor
     */
    function LocalStorageUtils($window) {
        return{
            //存储单个属性
            set :function(key,value){
                $window.localStorage[key]=value;
            },
            //读取单个属性
            get:function(key){
                return  $window.localStorage[key];
            },
            //存储对象，以JSON格式存储
            setObject:function(key,value){
                $window.localStorage[key]=JSON.stringify(value);
            },
            //读取对象
            getObject: function (key) {
                return JSON.parse($window.localStorage[key] || '{}');
            }
        }
    }
})();




/**
 * Created by hxpeng on 2017/4/27.
 */

(function () {
    'use strict';

    LoginAccountAuth.$inject = ["store", "AppUtils", "$q", "Global", "$http"];
    angular.module('App.common')
        .factory("LoginAccountAuth",LoginAccountAuth)


    function LoginAccountAuth(store,AppUtils,$q,Global,$http) {

        var service = {};
        service.isLoginIn = isLoginIn;
        service.getAccount = getAccount;
        service.setAccount = setAccount;
        service.httpGetLoginAccount =httpGetLoginAccount;
        service.getLastGotoUrl = getLastGotoUrl;
        service.setLastGotoUrl = setLastGotoUrl;
        return service;

        function isLoginIn(){
            var obj = store.get("loginAccount");
            if(AppUtils.isUndefinedOrNull(obj) || AppUtils.isUndefinedOrNull(obj.memberId)){
                return false;
            }else{
                return true;
            }
        }

        /**
         * 获取用户信息
         * @returns {*}
         */
        function getAccount(){
            var deferred = $q.defer();
            var account = store.get("loginAccount");
            if(AppUtils.isUndefinedOrNull(account)) {
                httpGetLoginAccount()
                    .then(function (data) {
                        if (data !== null) {
                            deferred.resolve(data);
                        }
                    });
            }else{
                deferred.resolve(account);
            }
            return deferred.promise;
        }


        /**
         * 临时缓存获取不到用户信息时，从后台获取
         * @returns {*}
         */
        function httpGetLoginAccount(){
            var deferred = $q.defer();
            $http.post(Global.path.server_wechat_test_path, {})
                .success(function (response) {
                    var obj = response.loginAccountVo;
                    setAccount(obj);
                    deferred.resolve(obj);
                })
                .error(function (data) {
                    deferred.reject(data);
                    AppUtils.showAlert("请求异常，请稍后再试！");
                })
            return deferred.promise;
        }

        /**
         * 将用户信息存入临时缓存中
         * @param account
         */
        function setAccount(account){
            store.set('loginAccount', account);
        }

        /**
         * 保存被拦截之前要访问的URL
         */
        function setLastGotoUrl(url){
            store.set('goToUrl', url);
        }

        /**
         * 获取被拦截之前要访问的URL
         */
        function getLastGotoUrl(){
            return store.get('goToUrl');
        }
    }
})();

/**
 * Created by hxpeng on 2017/4/30.
 */
(function () {
    'use strict';

    StoreUtils.$inject = ["AppUtils", "store"];
    angular.module('App.common')
        .service('StoreUtils', StoreUtils);

    /**
     * 缓存工具类
     */
    function StoreUtils(AppUtils,store) {

        return {
            setObj: function setObj(key,obj) {
                if(!AppUtils.isUndefinedOrNull(key) && !AppUtils.isUndefinedOrNull(obj)){
                    store.set(key, obj);
                }
            },
            getObj: function getObj(key){
                return store.get(key);
            },
            removeObj: function removeObj(key){
                store.remove(key);
            }
        }
    }
})();
/**
 * Created by dzd on 2017/3/24.
 */
(function () {
    'use strict';

    ClassActivityCtrl.$inject = ["$scope", "$state", "ClassActivityModel", "AppUtils"];
    angular.module('App.pages.class')
        .controller('ClassActivityCtrl', ClassActivityCtrl);

    function ClassActivityCtrl($scope,$state,ClassActivityModel,AppUtils) {

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });
        $scope.gotoDetail = function(activityId){
            if(!AppUtils.isUndefinedOrNull(activityId)){
                $state.go("classMenu.activityInfo",{activityId:activityId});
            }else{
                AppUtils.showAlert("请选择要查看的活动！");
            }
        }

        var vm = this;
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 1;//第一页

        $scope.loadMoreActivity = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.getActivityPage();
            }
        }

        vm.getActivityPage = function(){
            ClassActivityModel.getActivityPage({
                classId : 88,
                pageInfo: {
                    pageSize: 5,
                    pageNumber: vm.pageIndex
                }
            }).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                    angular.forEach(items,function(data){
                        vm.exhortaions.push(data);
                    })
                }
            })
        }
        vm.getActivityPage();
    }
})();
/**
 * Created by dzd on 2017/3/24.
 */
(function () {
    'use strict';

    ClassActivityInfoCtrl.$inject = ["activityId", "$scope", "$state", "AppUtils", "ClassActivityModel"];
    angular.module('App.pages.class')
        .controller('ClassActivityInfoCtrl', ClassActivityInfoCtrl);

    function ClassActivityInfoCtrl(activityId,$scope,$state,AppUtils,ClassActivityModel) {

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });

        var vm = this;
        vm.classActivity = {};
        vm.init = function(){
            if(!AppUtils.isUndefinedOrNull(activityId)){
                ClassActivityModel.findClassActivity({id: activityId}).$promise.then(function(response){
                    if(response.stat == 'err'){
                        AppUtils.showAlert(response.msg);
                    }else{
                        vm.classActivity = response.classActivity;
                    }
                })
            }else{
                AppUtils.showAlert("未找到该活动！");
                $state.go("classMenu.classActivity",activityId);
            }
        }
        vm.init();
    }
})();


/**
 * Created by dzd on 2017/3/24.
 */

(function () {
    'use strict';

    ClassActivityModel.$inject = ["API", "$resource"];
    angular.module('App.pages.class')
        .service('ClassActivityModel', ClassActivityModel);

    function ClassActivityModel(API,$resource) {
        this.actions = {}

        this.actions.findClassActivity = {
            method: 'GET',
            url: API + '/activity/wechat/findClassActivity'
        }

        this.actions.getActivityPage = {
            method: 'POST',
            url: API + '/activity/wechat/getActivityPage'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ClassCtrl.$inject = ["$scope", "$ionicSlideBoxDelegate"];
    angular.module('App.pages.class')
        .controller('ClassCtrl', ClassCtrl);

    function ClassCtrl($scope,$ionicSlideBoxDelegate) {

        var vm = this;
        $scope.next = function() {
            $ionicSlideBoxDelegate.next();
        };
        $scope.previous = function() {
            $ionicSlideBoxDelegate.previous();
        };
        $scope.slideChanged = function(index) {
            $scope.slideIndex = index;
        };
        $ionicSlideBoxDelegate.loop(true); //解决轮播至最后一个不轮播的问题

    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ClassInfoCtrl.$inject = ["$scope", "ClassInfoModel", "AppUtils", "LoginAccountAuth", "$ionicSlideBoxDelegate", "MemberModel"];
    angular.module('App.pages.class')
        .controller('ClassInfoCtrl', ClassInfoCtrl);

    function ClassInfoCtrl($scope,ClassInfoModel,AppUtils,LoginAccountAuth,$ionicSlideBoxDelegate,MemberModel) {

        $scope.next = function() {
            $ionicSlideBoxDelegate.next();
        };
        $scope.previous = function() {
            $ionicSlideBoxDelegate.previous();
        };
        $scope.slideChanged = function(index) {
            $scope.slideIndex = index;
        };

        $ionicSlideBoxDelegate.loop(true); //解决轮播至最后一个不轮播的问题



        var vm = this;
        vm.loginAccount = {};
        vm.classInfo = {};
        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccount = data;
            var memberId = "";
            if(vm.loginAccount.memberType == 2){
                memberId = vm.loginAccount.studentId;
            }else{
                memberId = vm.loginAccount.memberId;
            }
            ClassInfoModel.classInfo({memberId: memberId}).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    vm.classInfo = response.schoolClass;
                    vm.getStudentPage();
                }
            })
        })

        vm.items = [];
        vm.pageIndex = 1;
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";

        $scope.loadMoreEntrust = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.getStudentPage();
            }
        }

        vm.getStudentPage = function(){
            MemberModel.getStudentList({
                classId: vm.loginAccount.classId,
                pageInfo: {
                    pageSize: 10,
                    pageNumber: vm.pageIndex
                }
            }).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                    angular.forEach(items,function(data){
                        vm.items.push(data);
                    })
                }
            })
        }

    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    ClassInfoModel.$inject = ["API", "$resource"];
    angular.module('App.pages.class')
        .service('ClassInfoModel', ClassInfoModel);

    function ClassInfoModel(API,$resource) {
        this.actions = {}
        this.actions.classInfo = {
            method: 'GET',
            url: API + '/class/findClassByMemberId'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }

})();
/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider"];
    angular.module('App.pages.class.msg', [])
        .config(routeConfig);

    function routeConfig($stateProvider) {
        $stateProvider.state('msg', {
            url: "/msg",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('msg.list', {
            url: "/list",
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/msg/msg-list.html',
                    controller:'MsgListCtrl as vm'
                }
            }
        }).state('msg.voice', {
            url: "/voice",
            params:{
                "toMemberId":null
            },
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/msg/msg-voice.html',
                    controller:'NewAudioMsgCtrl as vm'
                }
            }
        }).state('msg.text', {
            url: "/text",
            params:{
                "studentArray":null
            },
            cache: false,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/class/msg/msg-text.html',
                    controller:'NewTextMsgCtrl as vm'
                }
            }
        });
    }
})();
/**
 * Created by hxpeng on 2017/5/11.
 */
(function () {
    'use strict';

    MsgService.$inject = ["$q", "MsgModel", "AppUtils", "LoginAccountAuth"];
    angular.module('App.pages.class.msg')
        .factory("MsgService",MsgService);

    function MsgService($q,MsgModel,AppUtils,LoginAccountAuth) {

        var service = {
            loadMsgPage: loadMsgPage,
            createMsg: createMsg,
            deleteMsg: deleteMsg
        };

        function loadMsgPage(params){
            var deferred = $q.defer();
            MsgModel.findMsgPage(params).$promise.then(function(response){
                deferred.resolve(response);
            })
            return deferred.promise;
        }

        function createMsg(){

        }
        function deleteMsg(){

        }

        return service;
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    MsgCtrl.$inject = ["$scope", "$state", "$stateParams", "AppUtils", "MsgModel"];
    angular.module('App.pages.class.msg')
        .controller('MsgCtrl', MsgCtrl);

    function MsgCtrl($scope,$state,$stateParams,AppUtils,MsgModel) {

        var vm = this;
        vm.disableSubmitBtn = false;
        vm.msgInfo = {};


        //var loginAccount = store.get("loginAccount");
        //loginAccount.memberId;

        vm.msgInfo.memberId = "";
        vm.msgInfo.toMemberId = $stateParams.toMemberId;

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });

        if(AppUtils.isUndefinedOrNull($stateParams.toMemberId)){
            AppUtils.showAlert("留言必要参数为空！");
            $state.go("memberMenu.parentInfo");
            vm.disableSubmitBtn = true;
        }

        $scope.saveMsgInfo = function(){
            if(AppUtils.isUndefinedOrNull(vm.msgInfo.msgContent)){
                AppUtils.showAlert("请输入留言内容！");
                return false;
            }
            MsgModel.createNewMsg(vm.msgInfo).$promise.then(function(response){
                var result = response.result;
                if(!AppUtils.isUndefinedOrNull(result) && result == 'success'){
                    AppUtils.showAlert("留言成功！");
                    AppUtils.goBack();
                }
            })
        }
    }
})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    MsgListCtrl.$inject = ["$scope", "AppUtils", "MsgService"];
    angular.module('App.pages.class.msg')
        .controller('MsgListCtrl', MsgListCtrl);

    function MsgListCtrl($scope,AppUtils,MsgService) {

        var vm = this;
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.pageIndex = 0;

        $scope.loadMoreMsg = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.getMsgPage();
            }
        }

        vm.getMsgPage = function(){
            var params = {};
            params.pageInfo = {};
            params.pageInfo.pageSize = 10;
            params.pageInfo.pageNumber = vm.pageIndex;

            MsgService.loadMsgPage(params).then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                    }
                    angular.forEach(items,function(data){
                        vm.exhortaions.push(data);
                    })
                }
            }).finally(function() {
                // Stop the ion-refresher from spinning
                $scope.$broadcast('scroll.infiniteScrollComplete');
            });
        }
    }
})();

/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    MsgModel.$inject = ["API", "$resource"];
    angular.module('App.pages.class.msg')
        .service('MsgModel', MsgModel);

    function MsgModel(API,$resource) {
        this.actions = {}
        this.actions.createNewMsg = {
            method: 'POST',
            url: API + '/msg/createNewMsg'
        }

        this.actions.findMsgPage = {
            method: 'POST',
            url: API + '/msg/findMsgPageInfo'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    NewAudioMsgCtrl.$inject = ["$scope", "AppUtils", "$location", "$http", "Global", "$timeout", "MsgModel", "$stateParams"];
    angular.module('App.pages.class.msg')
        .controller('NewAudioMsgCtrl', NewAudioMsgCtrl);

    function NewAudioMsgCtrl($scope,AppUtils,$location,$http,Global,$timeout,MsgModel,$stateParams) {
        var recordingTime,start,end;
        var currentPath = $location.url();

        var vm = this;
        if(AppUtils.isUndefinedOrNull($stateParams.toMemberId)){
            AppUtils.showAlert("请选择宝宝留言");
            AppUtils.goBack();
        }
        vm.recordAuth = false;
        vm.init = function(){
            if(currentPath.indexOf("#") != -1){
                currentPath = currentPath.split('#')[0];
            }
            currentPath = Global.path.wechat_path + currentPath;
            $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
                .success(function(data){
                    wx.config({
                        debug: false,
                        appId: data.appId,
                        timestamp: data.timestamp,
                        nonceStr: data.noncestr,
                        signature: data.signature,
                        jsApiList: ['startRecord','stopRecord','onVoiceRecordEnd','playVoice','pauseVoice','stopVoice','onVoicePlayEnd','uploadVoice']
                    });
                    wx.ready(function(){
                        wx.startRecord({
                            success: function(){
                                vm.recordAuth = true;
                                wx.stopRecord();
                            },
                            cancel: function () {
                                alert('用户拒绝授权录音');
                            }
                        });
                    });
                    wx.error(function(res){
                        console.log(res);

                    });
                })
                .error(function(data,header,config,status){
                    alert("请求微信sdk校验异常");
                });
        }


        $('#record-btn').on('touchstart', function(event){
            event.preventDefault();
            if(vm.recordAuth){
                $(".spinner").addClass("recording");
                start = new Date().getTime();
                var recordingTime = $timeout(function() {
                    wx.startRecord({
                        success: function(){
                        },
                        cancel: function () {
                            alert('用户拒绝授权录音');
                        }
                    });
                },100);
            }else{
                alert('您已拒绝授权录音了。。');
            }
        });
        //松手结束录音
        $('#record-btn').on('touchend', function(event){
            event.preventDefault();
            $(".spinner").removeClass("recording");
            end = new Date().getTime();
            if((end - start) < 1500){
                end = 0;
                start = 0;
                //小于300ms，不录音
                clearTimeout(recordingTime);
            }else{
                wx.stopRecord({
                    success: function (res) {
                        wx.playVoice({
                            localId: res.localId // 需要播放的音频的本地ID，由stopRecord接口获得
                        });
                        var recordConfirm = AppUtils.showConfirm("确认上传录音吗？");
                        recordConfirm.then(function(result) {
                            if(result) {
                                AppUtils.loading();
                                wx.uploadVoice({
                                    localId: res.localId, // 需要上传的音频的本地ID，由stopRecord接口获得
                                    isShowProgressTips: 0, // 默认为1，显示进度提示
                                    success: function (uploadVoiceRes) {
                                        var obj = {};
                                        obj.mediaId = uploadVoiceRes.serverId;
                                        obj.msgType = 'audio';
                                        obj.toMemberId = $stateParams.toMemberId;
                                        MsgModel.createNewMsg(obj).$promise.then(function(response){
                                            if(response.stat == 'err'){
                                                AppUtils.showAlert(response.msg);
                                            }else{
                                                AppUtils.showTipsTop("上传成功！");
                                            }
                                            AppUtils.loadfinish();
                                        })
                                    }
                                });
                            } else {
                                console.log('You are not sure');
                            }
                        });
                    },
                    fail: function (res) {
                        alert(JSON.stringify(res));
                    }
                });
            }
        });


        $scope.$on('$ionicView.beforeLeave', function(){
            wx.stopRecord();
        });

        vm.init();
    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    NewTextMsgCtrl.$inject = ["$scope", "$stateParams", "AppUtils", "MsgModel", "$state"];
    angular.module('App.pages.class.msg')
        .controller('NewTextMsgCtrl', NewTextMsgCtrl);

    function NewTextMsgCtrl($scope,$stateParams,AppUtils,MsgModel,$state) {

        var vm = this;
        vm.msgInfo = {};
        vm.msgInfo.msgType = "text";
        vm.msgInfo.studentIds = $stateParams.studentArray;
        if(AppUtils.isUndefinedOrNull($stateParams.studentArray) || vm.msgInfo.studentIds.length < 1){
            AppUtils.showAlert("请选择宝宝留言");
            AppUtils.goBack();
        }

        $scope.saveMsgInfo = function(){
            if(AppUtils.isUndefinedOrNull(vm.msgInfo.msgContent)){
                AppUtils.showAlert("请输入留言内容！");
                return false;
            }
            MsgModel.createNewMsg(vm.msgInfo).$promise.then(function(response){
                var result = response.result;
                if(!AppUtils.isUndefinedOrNull(result) && result == 'success'){
                    AppUtils.showAlert("留言成功！");
                    $state.go("classMenu.teacherIndex");
                }else{
                    AppUtils.showAlert(response.msg);
                }
            })
        }
    }
})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    StudentCtrl.$inject = ["studentId", "AppUtils", "$scope", "MemberModel"];
    angular.module('App.pages.member')
        .controller('StudentCtrl', StudentCtrl);

    function StudentCtrl(studentId,AppUtils,$scope,MemberModel) {
        if(AppUtils.isUndefinedOrNull(studentId)){
            AppUtils.showTipsTop("请选择一个宝宝操作！");
            AppUtils.goBack();
        }
        var vm =this;
        vm.studentId = studentId;
        vm.studentHadBind = false;


        MemberModel.studentHadBind({memberId:vm.studentId}).$promise.then(function(response){
            if(response.result == 'err'){
                AppUtils.showAlert(response.msg);
            }else{
                if(response.result == 'yse'){
                    vm.studentHadBind = true;
                    console.log(vm.studentHadBind);
                }
            }
        })




        vm.clientType = AppUtils.getClientType();
        if(vm.clientType === "ios"){
            vm.showMenuBoxType = "ios";
            var $iosActionsheet = $('#iosActionsheet');
            var $iosMask = $('#iosMask');
            var hideActionSheet = function() {
                $iosActionsheet.removeClass('weui-actionsheet_toggle');
                $iosMask.fadeOut(200);
            }
            $iosMask.on('click', hideActionSheet);
            $('#iosActionsheetCancel').on('click', hideActionSheet);
            $("#showIOSActionSheet").on("click", function(){
                $iosActionsheet.addClass('weui-actionsheet_toggle');
                $iosMask.fadeIn(200);
            });
        }else{
            vm.showMenuBoxType = "android";
            var $androidActionSheet = $('#androidActionsheet');
            var $androidMask = $androidActionSheet.find('.weui-mask');
            $("#showAndroidActionSheet").on('click', function(){
                $androidActionSheet.fadeIn(200);
                $androidMask.on('click',function () {
                    $androidActionSheet.fadeOut(200);
                });
            });
        }

        $scope.$on('$ionicView.beforeLeave', function(){
            $(".weui-mask").click();
            $("#iosActionsheetCancel").click();
        });

        //
        //$scope.$on('$ionicView.beforeEnter', function (event, viewData) {
        //    viewData.enableBack = true;
        //});
        //
        //var vm = this;
        //vm.parentId = '';
        //
        //var objParams = {};
        ////objParams.memberId = '041DFD58D85D31A478B881F1EBE4ECA9';
        ////objParams.relType = 'father';
        //objParams.memberId = studentId;
        //objParams.relType = 'father';
        //MemberModel.getParentId(objParams).$promise.then(function(response){
        //    if(response.stat == 'err'){
        //        AppUtils.showAlert(response.msg);
        //        AppUtils.goBack();
        //    }else if(response.stat == 'success'){
        //        vm.parentId = response.parentId;
        //    }
        //})
    }
})();
/**
 * Created by dzd on 2017/3/24.
 */
(function () {
    'use strict';

    ClassNoticeCtrl.$inject = ["$state", "$scope", "ClassNoticeModel", "AppUtils"];
    angular.module('App.pages.class')
        .controller('ClassNoticeCtrl', ClassNoticeCtrl);

    function ClassNoticeCtrl($state,$scope,ClassNoticeModel,AppUtils) {

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });

        $scope.gotoDetail = function(noticeId){
            if(!AppUtils.isUndefinedOrNull(noticeId)){
                $state.go("classMenu.noticeInfo",{noticeId:noticeId});
            }else{
                AppUtils.showAlert("请选择要查看的活动！");
            }
        }

        var vm = this;
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 1;//第一页

        $scope.loadMoreNotice = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.getNoticePage();
            }
        }
        vm.getNoticePage = function(){
            ClassNoticeModel.getNoticePage({
                classId : 18,
                pageInfo: {
                    pageSize: 5,
                    pageNumber: vm.pageIndex
                }
            }).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                    angular.forEach(items,function(data){
                        vm.exhortaions.push(data);
                    })
                }
            })
        }
        vm.getNoticePage();
    }

})();

/**
 * Created by dzd on 2017/3/24.
 */
(function () {
    'use strict';

    ClassNoticeInfoCtrl.$inject = ["noticeId", "$state", "$scope", "ClassNoticeModel", "AppUtils"];
    angular.module('App.pages.class')
        .controller('ClassNoticeInfoCtrl', ClassNoticeInfoCtrl);

    function ClassNoticeInfoCtrl(noticeId,$state,$scope,ClassNoticeModel,AppUtils) {

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });

        var vm = this;
        vm.classNotice = {};
        vm.init = function(){
            if(!AppUtils.isUndefinedOrNull(noticeId)){
                ClassNoticeModel.findClassNotice({id: noticeId}).$promise.then(function(response){
                    if(response.stat == 'err'){
                        AppUtils.showAlert(response.msg);
                    }else{
                        vm.classNotice = response.classNotice;
                    }
                })
            }else{
                AppUtils.showAlert("未找到该活动！");
                $state.go("classMenu.classNotice",noticeId);
            }
        }
        vm.init();
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';

    ClassNoticeModel.$inject = ["API", "$resource"];
    angular.module('App.pages.class')
        .service('ClassNoticeModel', ClassNoticeModel);

    function ClassNoticeModel(API,$resource) {
        this.actions = {}
        this.actions.findClassNotice = {
            method: 'GET',
            url: API + '/notice/wechat/findClassNotice'
        }
        this.actions.getNoticePage = {
            method: 'POST',
            url: API + '/notice/wechat/getNoticePage'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    TeacherCtrl.$inject = ["$scope", "MemberModel", "LoginAccountAuth", "AppUtils", "$state"];
    angular.module('App.pages.class')
        .controller('TeacherCtrl', TeacherCtrl);

    function TeacherCtrl($scope,MemberModel,LoginAccountAuth,AppUtils,$state) {

        var vm = this;
        vm.items = [];
        vm.pageIndex = 1;
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.loginAccount = {};
        vm.teacherInfo = {};
        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccount = data;
            MemberModel.getMemberInfo({id:data.memberId}).$promise.then(function(response){
                if(!AppUtils.isUndefinedOrNull(response.memberInfo)){
                    vm.teacherInfo = response.memberInfo;
                }else {
                    AppUtils.showTipsTop("未查询到教师信息！");
                }
            })
        })
        $scope.editMemberInfo = function(){
            $state.go("memberMenu.edit");
        }
    }
})();

/**
 * Created by hxpeng on 2017/5/18.
 */
(function () {
    'use strict';

    AddAlbumCtrl.$inject = ["$scope", "AppUtils", "$location", "$http", "Global", "MemberModel", "$state"];
    angular.module('App.pages.member')
        .controller('AddAlbumCtrl', AddAlbumCtrl);

    function AddAlbumCtrl($scope,AppUtils,$location,$http,Global,MemberModel,$state) {
        var vm = this;
        vm.imgIndex = 0;//imgUrl中保存的图片唯一标识符
        vm.imgUrl = [];//页面预览图片数组
        vm.postImgArray = [];//提交后台图片serverId数组
        $scope.localIds = "";


        $scope.$on('$ionicView.enter', function(){
            var currentPath = $location.url();
            if(currentPath.indexOf("#") != -1){
                currentPath = currentPath.split('#')[0];
            }
            currentPath = Global.path.wechat_path + currentPath;
            $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
                .success(function(data){
                    wx.config({
                        debug: false,
                        appId: data.appId,
                        timestamp: data.timestamp,
                        nonceStr: data.noncestr,
                        signature: data.signature,
                        jsApiList: ['scanQRCode','chooseImage','previewImage','uploadImage']
                    });
                    wx.ready(function(){
                        console.log(1);
                    });
                    wx.error(function(res){
                        alert(JSON.stringify(res));
                        console.log(res);
                    });
                })
                .error(function(data,header,config,status){
                    alert("请求微信sdk校验异常");
                });
        });



        $scope.chooseImg = function(){
            wx.chooseImage({
                count: 9,
                sizeType: ['original', 'compressed'],
                sourceType: ['album', 'camera'],
                success: function (res) {
                    var localIds = res.localIds;
                    syncPutImg(localIds);
                    AppUtils.loading();
                }
            });
        }

        //同步上传图片
        var syncPutImg = function(localIds){
            var img = localIds.pop();
            wx.uploadImage({
                localId: img,
                isShowProgressTips: 0,
                success: function (res) {
                    var serverId = res.serverId; // 返回图片的服务器端ID
                    var obj = {};
                    obj.imgIndex = vm.imgIndex;
                    obj.url = img;
                    obj.serverId = serverId;
                    $scope.$apply(function(){
                        vm.imgUrl.push(obj);
                    });
                    vm.imgIndex++;
                    if(localIds.length > 0){
                        syncPutImg(localIds);
                    }else{
                        AppUtils.loadfinish();
                    }
                }
            });
        };

        //大图片预览
        $scope.previewImg = function(url){
            var imgArray = [];
            angular.forEach(vm.imgUrl, function(obj, index) {
                imgArray.push(obj.url);
            });
            wx.previewImage({
                current: url,
                urls: imgArray
            });
        }

        //删除选择的图片
        $scope.removePicture = function(url,imgIndex){
            var urlIndex = null;
            angular.forEach(vm.imgUrl, function(obj, index) {
                if (obj.url === url && obj.imgIndex === imgIndex) {
                    urlIndex = index;
                }
            });
            $scope.$apply(function(){
                vm.imgUrl.splice(urlIndex, 1);
            });
        }


        $scope.uploadImg = function(){
            if(!AppUtils.isUndefinedOrNull(vm.imgUrl)){
                angular.forEach(vm.imgUrl, function(obj, index) {
                    if (!AppUtils.isUndefinedOrNull(obj.serverId)) {
                        vm.postImgArray.push(obj.serverId);
                    }
                });
            }
            MemberModel.submitUploadImg({serverIds: JSON.stringify(vm.postImgArray)}).$promise.then(function(response){
                if(response.stat == 'success'){
                    AppUtils.showAlert("提交成功！");
                    $state.go("memberMenu.albumIndex");
                }else if(response.stat == 'err'){
                    AppUtils.showAlert("提交失败:" + response.msg);
                }
            });
        }

    }

})();
/**
 * Created by hxpeng on 2017/5/18.
 */
(function () {
    'use strict';

    AlbumCtrl.$inject = ["$scope", "$state", "MemberModel", "$location", "$http", "Global", "$filter", "LoginAccountAuth", "AppUtils"];
    angular.module('App.pages.member')
        .controller('AlbumCtrl', AlbumCtrl);

    function AlbumCtrl($scope,$state,MemberModel,$location,$http,Global,$filter,LoginAccountAuth,AppUtils) {
        var currentPath = $location.url();
        if(currentPath.indexOf("#") != -1){
            currentPath = currentPath.split('#')[0];
        }
        currentPath = Global.path.wechat_path + currentPath;
        $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
            .success(function(data){
                wx.config({
                    debug: false,
                    appId: data.appId,
                    timestamp: data.timestamp,
                    nonceStr: data.noncestr,
                    signature: data.signature,
                    jsApiList: ['chooseImage','previewImage']
                });
                wx.error(function(res){
                    console.log(res);

                });
            })
            .error(function(data,header,config,status){
                alert("请求微信sdk校验异常");
            });


        $scope.photo = function(){
            $state.go("memberMenu.upload");
        }
        var vm = this;
        vm.loginAccount = {};
        vm.memberIds = [];
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 1;//第一页
        vm.imgPre = Global.path.img_path;

        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccount = data;
            angular.forEach(vm.loginAccount.studentVoList,function(obj){
                vm.memberIds.push(obj.memberId);
            })
            vm.init();
        })



        $scope.loadMoreActivity = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.init();
            }
        }

        //大图片预览
        $scope.previewImg = function(url,key){
            var imgArray = [];
            angular.forEach($scope.resultArray, function(data) {
                if(data.key == key){
                    angular.forEach(data.timeArray, function(val) {
                        imgArray.push(val.url);
                    });
                }
            });
            wx.previewImage({
                current: url,
                urls: imgArray
            });
        }


        $scope.resultArray = [];

        vm.init = function(){
            AppUtils.loading();
            MemberModel.queryStudentsPhoto({
                memberIds: vm.memberIds,
                pageInfo: {
                    pageSize: 5,
                    pageNumber: vm.pageIndex
                }
            }).$promise.then(function(response){
                var reponseDate = response.classPhoto;
                if(AppUtils.isUndefinedOrNull(reponseDate)){
                    vm.loadMoreBtnStatus = false;
                    vm.loadMoreBtnStr = "没有更多数据了";
                    return;
                }
                var items = reponseDate.pageResult;
                var pageIndex = reponseDate.pageIndex;
                var pageTotalPageSize = reponseDate.pageTotalPageSize;
                if(pageIndex == pageTotalPageSize || items.length == 0){
                    vm.loadMoreBtnStatus = false;
                    vm.loadMoreBtnStr = "没有更多数据了";
                }

                var repeat = [];
                angular.forEach (items,function(data,index,array){
                    var keepRun = true;
                    var key = $filter("date")(new Date(data.createDate), "yyyy-MM-dd");
                    angular.forEach(repeat,function(i){
                        if(key == i){
                            keepRun = false;
                        }
                    });

                    if(keepRun){
                        var obj = {};
                        obj.key = key;
                        var timeArray = [];
                        angular.forEach (items,function(object,k){
                            var time = $filter("date")(new Date(object.createDate), "yyyy-MM-dd");
                            if(key == time){
                                var imgObj = {};
                                imgObj.url = object.filePath;
                                imgObj.key = key;
                                timeArray.push(imgObj);
                            }
                        })
                        obj.timeArray = timeArray;
                        $scope.resultArray.push(obj);
                        repeat.push(key);
                        AppUtils.loadfinish();
                    }
                })
            })
        }

        //悬浮菜单
        $("#hamburgerMenuBtn").on("click",function () {
            $("#hamburgerMenuBtn").toggleClass("active");
        });

        var lastTop = 0;
        $scope.scrollFun = function(){
            var top = $ionicScrollDelegate.$getByHandle('albumScroll').getScrollPosition().top;
            if(top > 200 && top > lastTop){
                $("#hamburgerMenuBtn").removeClass("active");
                $("#hamburgerMenuBtn").css("right","-80px")
            }else if(lastTop - top > 20){
                $("#hamburgerMenuBtn").css("right","40px")
            }
            lastTop = top;
        }

    }
})();

/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    routeConfig.$inject = ["$stateProvider"];
    angular.module('App.pages.member.entrust', [])
        .config(routeConfig);

    function routeConfig($stateProvider) {
        $stateProvider.state('entrust', {
            url: "/entrust",
            abstract: true,
            templateUrl: 'source/pages/page-tab.html',
        }).state('entrust.create', {
            url: "/create/{entrustId:string}",
            cache: false,
            params: {
                entrustId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/entrust/entrust-create.html',
                    controller:'NewEntrustCtrl as vm',
                    resolve: {
                        entrustId: ["$stateParams", function($stateParams){
                            return $stateParams.entrustId;
                        }]
                    }
                }
            }
        }).state('entrust.entrustInfo', {
            url: "/entrustInfo/{entrustId:string}",
            cache: false,
            params: {
                entrustId: null
            },
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/entrust/entrust-info.html',
                    controller:'EntrustInfoCtrl as vm',
                    resolve: {
                        entrustId: ["$stateParams", function($stateParams){
                            return $stateParams.entrustId;
                        }]
                    }
                }
            }
        }).state('entrust.parentEntrustList', {
            url: "/parentEntrustList",
            cache: true,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/entrust/parent-entrust-list.html',
                    controller:'ParentEntrustCtrl as vm'
                }
            }
        }).state('entrust.teacherEntrustList', {
            url: "/teacherEntrustList",
            cache: true,
            views: {
                'kinder-view': {
                    templateUrl: 'source/pages/member/entrust/teacher-entrust-list.html',
                    controller:'TeacherEntrustCtrl as vm'
                }
            }
        });
    }
})();
/**
 * Created by hxpeng on 2017/5/11.
 */
(function () {
    'use strict';

    EntrustService.$inject = ["$q", "EntrustModel", "AppUtils", "$timeout", "$state"];
    angular.module('App.pages.member.entrust')
        .factory("EntrustService",EntrustService);

    function EntrustService($q,EntrustModel,AppUtils,$timeout,$state) {

        var service = {
            loadEntrustPage: loadEntrustPage,
            loadEntrustInfo: loadEntrustInfo,
            createEntrust: createEntrust,
            deletedEntrust: deletedEntrust
        };

        function loadEntrustPage(params){
            var deferred = $q.defer();
            EntrustModel.getEntrustPage(params).$promise.then(function(response){
                deferred.resolve(response);
            })
            return deferred.promise;
        }

        function loadEntrustInfo(entrustId){
            var deferred = $q.defer();
            EntrustModel.getEntrustInfo({entrustId: entrustId}).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                    deferred.resolve(null);
                }else{
                    deferred.resolve(response.entrust);
                }
            })
            return deferred.promise;
        }
        function createEntrust(obj){
            var deferred = $q.defer();
            EntrustModel.saveEntrust(obj).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    AppUtils.showTipsTop("提交成功！");
                    $timeout(function(){
                        $state.go("entrust.parentEntrustList");
                    },1000)
                }
                deferred.resolve(null);
            })
            return deferred.promise;
        }
        function deletedEntrust(){

        }

        return service;
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    EntrustInfoCtrl.$inject = ["entrustId", "$scope", "EntrustModel", "AppUtils", "EntrustService", "$timeout", "$state", "LoginAccountAuth", "$interval", "$stateParams"];
    angular.module('App.pages.member.entrust')
        .controller('EntrustInfoCtrl', EntrustInfoCtrl);

    function EntrustInfoCtrl(entrustId,$scope,EntrustModel,AppUtils,EntrustService,$timeout,$state,LoginAccountAuth,$interval,$stateParams) {

        var vm = this;
        vm.loginAccount = {};
        vm.entrust = null;

        LoginAccountAuth.getAccount()
            .then(function(data){
                vm.loginAccount = data;
            });


        EntrustService.loadEntrustInfo(entrustId).then(function(data){
            $timeout(function() {
                vm.entrust = {};
                vm.entrust = data;
            }, 0);
        })

        $(".play-button").on("click",function() {
            $(".play-button").toggleClass("paused");
            $(".entrust-audio-play").toggleClass("playing");
        });

        vm.clientType = AppUtils.getClientType();
        if(vm.clientType === "ios"){
            vm.showMenuBoxType = "ios";
            var $iosActionsheet = $('#iosActionsheet');
            var $iosMask = $('#iosMask');
            var hideActionSheet = function() {
                $iosActionsheet.removeClass('weui-actionsheet_toggle');
                $iosMask.fadeOut(200);
            }
            $iosMask.on('click', hideActionSheet);
            $('#iosActionsheetCancel').on('click', hideActionSheet);
            $("#showIOSActionSheet").on("click", function(){
                $iosActionsheet.addClass('weui-actionsheet_toggle');
                $iosMask.fadeIn(200);
            });
        }else{
            vm.showMenuBoxType = "android";
            var $androidActionSheet = $('#androidActionsheet');
            var $androidMask = $androidActionSheet.find('.weui-mask');
            $("#showAndroidActionSheet").on('click', function(){
                $androidActionSheet.fadeIn(200);
                $androidMask.on('click',function () {
                    $androidActionSheet.fadeOut(200);
                });
            });
        }
        $scope.$on('$ionicView.beforeLeave', function(){
            $(".weui-mask").click();
            $("#iosActionsheetCancel").click();
        });


        $scope.deleteEntrust = function(entrustId){
            if(!AppUtils.isUndefinedOrNull(entrustId)){
                if(vm.entrust.entrustType === 'audio'){
                    $state.go("entrust.voice",{entrustId: vm.entrust.id});
                }else if(vm.entrust.entrustType === 'text'){
                    $state.go("entrust.text",{entrustId: vm.entrust.id});
                }
            }
        }


        $scope.executeEntrust = function(){
            if(!AppUtils.isUndefinedOrNull(vm.entrust.id)){
                EntrustModel.executedEntrust({entrustId:vm.entrust.id}).$promise.then(function(response){
                    if(response.stat == 'err'){
                        AppUtils.showAlert("执行失败：" + response.msg);
                    }else if(response.stat == 'success'){
                        AppUtils.showTipsTop("成功修改嘱托状态！");
                        $timeout(function(){
                            $state.go($state.current, $stateParams);
                        },1000)
                    }
                })
            }
        }


        //播放音频开始动作
        function playAudio(){
            $(".play-button").removeClass("paused");
            $(".entrust-audio-play").addClass("playing");
            if(!AppUtils.isUndefinedOrNull(vm.localAudioId)){
                wx.playVoice({
                    localId: vm.localAudioId // 需要播放的音频的本地ID，由stopRecord接口获得
                });
            }
        }
        //播放音频完成动作
        function pausedAudio(){
            $(".play-button").addClass("paused");
            $(".entrust-audio-play").removeClass("playing");
        }


        vm.isplaying = false;
        $scope.playAudio = function(){
            if(!vm.isplaying){
                var audio = $("audio")[0];
                var interval;
                var nprogress = $(".audio-nprogress")[0];
                if(!AppUtils.isUndefinedOrNull(audio)){
                    audio.addEventListener("playing", function() {
                        vm.isplaying = true;
                        playAudio();
                        var duration = Math.ceil(audio.duration*500);//总毫秒数
                        var count = duration/50;
                        var i = 100/count * 1000;
                        var s = 0;
                        interval = $interval(function(){
                            s = s + i;
                            nprogress.style.width =  s/1000 + "%";
                        }, 50, count);
                    }, false);
                    //音频可以播放完毕
                    audio.addEventListener("ended", function() {
                        vm.isplaying = false;
                        $timeout(function(){
                            pausedAudio();
                            nprogress.style.width = "0%";
                            $interval.cancel(interval);
                        },200)
                    }, false);
                    audio.play();
                }
            }

        }

    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */

(function () {
    'use strict';
    EntrustModel.$inject = ["API", "$resource"];
    angular.module('App.pages.member.entrust')
        .service('EntrustModel', EntrustModel);

    function EntrustModel(API,$resource) {
        this.actions = {}
        this.actions.getEntrustPage = {
            method: 'POST',
            url: API + '/entrust/getEntrustPage'
        }
        this.actions.getEntrustInfo = {
            method: 'GET',
            url: API + '/entrust/getEntrustInfo'
        }
        this.actions.saveEntrust = {
            method: 'POST',
            url: API + '/entrust/saveEntrust'
        }
        this.actions.executedEntrust = {
            method: 'GET',
            url: API + '/entrust/executedEntrust'
        }
        this.actions.deleteEntrust = {
            method: 'GET',
            url: API + '/entrust/deleteEntrust'
        }
        return $resource.call(this, this.url, this.params, this.actions)
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    NewEntrustCtrl.$inject = ["entrustId", "$scope", "AppUtils", "$state", "Global", "$location", "$http", "$timeout", "LoginAccountAuth", "EntrustService", "$interval"];
    angular.module('App.pages.member.entrust')
        .controller('NewEntrustCtrl', NewEntrustCtrl);

    function NewEntrustCtrl(entrustId,$scope,AppUtils,$state,Global,$location,$http,$timeout,LoginAccountAuth,EntrustService,$interval) {
        var vm = this;
        vm.entrust = {};
        vm.entrust.importantState = false;
        vm.entrustUseAudio = false;
        vm.audioMediaId = "";
        vm.localAudioId = "";
        vm.studentList = [];//家长绑定的孩子数字
        vm.chooseStudentList = [];//嘱托中选择的孩子
        vm.chooseStudentListTemp = [];
        vm.entrust.entrustType = 'text';
        vm.recordAuth = false;//是否授权录音
        vm.isEdit = false;//是否音频修改
        vm.isplaying = false;


        $scope.$on('$ionicView.enter', function(){
            var currentPath = $location.url();
            if(currentPath.indexOf("#") != -1){
                currentPath = currentPath.split('#')[0];
            }
            currentPath = Global.path.wechat_path + currentPath;
            $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
                .success(function(data){
                    wx.config({
                        debug: false,
                        appId: data.appId,
                        timestamp: data.timestamp,
                        nonceStr: data.noncestr,
                        signature: data.signature,
                        jsApiList: ['scanQRCode','startRecord','stopRecord','onVoiceRecordEnd','playVoice','pauseVoice','stopVoice','onVoicePlayEnd','uploadVoice']
                    });
                    wx.ready(function(){
                        wx.startRecord({
                            success: function(){
                                vm.recordAuth = true;
                                wx.stopRecord();
                            },
                            cancel: function () {
                                alert('用户拒绝授权录音');
                            }
                        });
                    });
                    wx.error(function(res){
                        alert(JSON.stringify(res));
                        console.log(res);
                    });
                })
                .error(function(data,header,config,status){
                    alert("请求微信sdk校验异常");
                });
        });




        var recordingTime,start,end;
        LoginAccountAuth.getAccount().then(function(data){
            angular.forEach(data.studentVoList,function(obj){
                if(!AppUtils.isUndefinedOrNull(obj.teacherId)){
                    vm.studentList.push(obj);
                }
            })
            vm.init();
        })

        //获取微信SDK授权
        vm.init = function(){
            //绑定播放按钮样式
            $(".play-button").on("click",function() {
                playAudio();
            });

            //页面初始化绑定事件
            $("#choose-child-btn,.entrust-create-screen").on("click",function(){
                $(".container").toggleClass('toggled');
            })
            $(".entrust-create-screen").on("click",".card-facebook",function(e){
                $(this).toggleClass('toggled');
                e.stopPropagation();
            })

            //往嘱托中添加宝宝
            $("#choose-student-btn").on("click",function(e){
                var keepGoing = true;
                var studentList = $(".entrust-create-screen").find(".card-facebook.toggled");
                studentList.each(function(){
                    var id = $(this).attr("data-studentId");
                    angular.forEach(vm.chooseStudentListTemp,function(data){
                        if(data.id === id){
                            keepGoing = false;
                            return;
                        }
                    })
                    if(keepGoing){
                        var obj = {};
                        obj.studentId = id;
                        obj.studentName = $(this).attr("data-studentName");
                        obj.studentAvatarPath = $(this).attr("data-studentAvatarPath");
                        obj.teacherName = $(this).attr("data-teacherName");
                        vm.chooseStudentListTemp.push(obj);
                    }
                    $(this).removeClass("toggled");
                })
                $scope.$apply(function () {
                    var obj = [];
                    var addToArray=true;
                    angular.forEach(vm.chooseStudentListTemp,function(a){
                        angular.forEach(vm.chooseStudentList,function(b){
                            if(b.studentId === a.studentId){
                                addToArray=false;
                                return;
                            }
                        })
                        if(addToArray){
                            vm.chooseStudentList.push(a);
                        }
                        addToArray=true;
                    })
                    vm.chooseStudentListTemp = [];
                    console.log(JSON.stringify(vm.chooseStudentList));
                });
            })

            //从嘱托中删除宝宝
            $scope.removeStudent = function(index){
                vm.chooseStudentList.splice(index, 1);
            }

            $('#record-btn').on('touchstart', function(event){
                event.preventDefault();
                if(vm.recordAuth){
                    $(".spinner").addClass("recording");
                    start = new Date().getTime();
                    var recordingTime = $timeout(function() {
                        wx.startRecord({
                            success: function(){
                            },
                            cancel: function () {
                                alert('用户拒绝授权录音');
                            }
                        });
                    },100);
                }else{
                    alert('获取录音权限失败，请稍后再试！');
                }
            });

            //松手结束录音
            $('#record-btn').on('touchend', function(event){
                event.preventDefault();
                $(".spinner").removeClass("recording");
                end = new Date().getTime();
                if((end - start) < 1500){
                    AppUtils.showTipsTop("录音太短啦，请重新录制!");
                    end = 0;
                    start = 0;
                    //小于300ms，不录音
                    clearTimeout(recordingTime);
                    wx.stopRecord();
                }else{
                    wx.stopRecord({
                        success: function (res) {
                            $("#audio-box").hide();
                            $(".record-play-div").show();
                            vm.localAudioId = res.localId;
                            playAudio();
                            wx.onVoicePlayEnd({
                                success: function (voicPlayEndRes) {
                                    pausedAudio();
                                }
                            });
                        },
                        fail: function (res) {
                            AppUtils.showAlert("微信录音失败" + JSON.stringify(res));
                        }
                    });
                }
            });

            if(!AppUtils.isUndefinedOrNull(entrustId)){
                EntrustService.loadEntrustInfo(entrustId).then(function(date){
                    if(!AppUtils.isUndefinedOrNull(date)){
                        vm.entrust = date;
                        if(vm.entrust.entrustType == "audio"){
                            vm.isEdit = true;
                            vm.entrustUseAudio = true;
                            vm.entrust.entrustType = 'audio';
                        }
                        if(vm.entrust.importantState == "true"){
                            vm.entrust.importantState = true;
                        }
                        angular.forEach(vm.studentList,function(obj){
                            if(obj.memberId == date.toEntrustChildId){
                                var student = {};
                                student.studentId = obj.memberId;
                                student.studentName = obj.memberName;
                                student.studentAvatarPath = obj.avatarPath;
                                student.teacherName = obj.teacherName;
                                vm.chooseStudentList.push(student);
                            }
                        })
                    }
                });
            }


            //播放音频开始动作
            function playAudio(){
                $(".play-button").removeClass("paused");
                $(".entrust-audio-play").addClass("playing");
                if(!vm.isplaying){
                    if(!AppUtils.isUndefinedOrNull(vm.localAudioId)){
                        wx.playVoice({
                            localId: vm.localAudioId // 需要播放的音频的本地ID，由stopRecord接口获得
                        });
                    }else{
                        if(vm.isEdit){
                            var audio = $("audio")[0];
                            var interval;
                            var nprogress = $(".audio-nprogress")[0];
                            if(!AppUtils.isUndefinedOrNull(audio)){
                                audio.addEventListener("playing", function() {
                                    vm.isplaying = true;
                                    var duration = Math.ceil(audio.duration*500);//总毫秒数
                                    var count = duration/50;
                                    var i = 100/count * 1000;
                                    var s = 0;
                                    interval = $interval(function(){
                                        s = s + i;
                                        nprogress.style.width =  s/1000 + "%";
                                    }, 50, count);
                                }, false);
                                //音频可以播放完毕
                                audio.addEventListener("ended", function() {
                                    vm.isplaying = false;
                                    $timeout(function(){
                                        pausedAudio();
                                        nprogress.style.width = "0%";
                                        $interval.cancel(interval);
                                    },200)
                                }, false);
                                audio.play();
                            }
                        }
                    }
                }


            }
            //播放音频完成动作
            function pausedAudio(){
                $(".play-button").addClass("paused");
                $(".entrust-audio-play").removeClass("playing");
            }


        }

        $scope.removeAudio = function(){
            $("#audio-box").show();
            $(".record-play-div").hide();
        }

        $scope.$on('$ionicView.beforeLeave', function(){
            wx.stopRecord();
        });

        //保存嘱托
        $scope.submitEntrust = function(){
            var obj = {};
            var studentList = [];
            angular.forEach(vm.chooseStudentList,function(data){
                studentList.push(data.studentId);
            })

            if(studentList.length < 1){
                AppUtils.showTipsTop("请选择宝宝！");
                return;
            }
            if(!AppUtils.isUndefinedOrNull(entrustId)){
                obj = _.clone(vm.entrust);
            }
            obj.studentIds = _.clone(studentList);
            obj.importantState = vm.entrust.importantState;

            if(vm.entrustUseAudio){
                if(AppUtils.isUndefinedOrNull(vm.localAudioId)){
                    AppUtils.showTipsTop("请按住麦克风录入嘱托！");
                    return;
                }
                var recordConfirm = AppUtils.showConfirm("确认上传录音吗？");
                recordConfirm.then(function(result) {
                    if(result) {
                        wx.uploadVoice({
                            localId: vm.localAudioId, // 需要上传的音频的本地ID，由stopRecord接口获得
                            isShowProgressTips: 1, // 默认为1，显示进度提示
                            success: function (uploadVoiceRes) {
                                obj.entrustType = 'audio';
                                obj.mediaId = uploadVoiceRes.serverId;
                                EntrustService.createEntrust(obj);
                            }
                        });
                    }
                });
            }else{
                if(AppUtils.isUndefinedOrNull(vm.entrust.entrustContent)){
                    AppUtils.showTipsTop("请输入嘱托内容！");
                    return;
                }
                obj.entrustType = 'text';
                obj.entrustContent = vm.entrust.entrustContent;
                EntrustService.createEntrust(obj);
            }
        }
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ParentEntrustCtrl.$inject = ["$scope", "$state", "AppUtils", "LoginAccountAuth", "EntrustService", "$sce", "$interval", "$timeout", "$ionicScrollDelegate"];
    angular.module('App.pages.member.entrust')
        .controller('ParentEntrustCtrl', ParentEntrustCtrl);

    function ParentEntrustCtrl($scope,$state,AppUtils,LoginAccountAuth,EntrustService,$sce,$interval,$timeout,$ionicScrollDelegate) {

        var vm = this;
        vm.loginAccount = {};
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 0;//第一页

        //首次进入
        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccount = data;
        });

        //往上拉加载更多
        $scope.loadMoreEntrust = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                //vm.pageIndex = 1;
                vm.getEntrustPage();
            }
        }

        vm.getEntrustPage = function(){
            var params = {};
            params.pageInfo = {};
            params.pageInfo.pageSize = 10;
            params.pageInfo.pageNumber = vm.pageIndex;

            EntrustService.loadEntrustPage(params).then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                    angular.forEach(items,function(data){
                        vm.exhortaions.push(data);
                    })
                }
            }).finally(function() {
                // Stop the ion-refresher from spinning
                $scope.$broadcast('scroll.infiniteScrollComplete');
            });
        }


        $scope.gotoDetail = function(entrustId){
            if(!AppUtils.isUndefinedOrNull(entrustId)){
                $state.go("entrust.entrustInfo",{entrustId:entrustId});
            }else{
                AppUtils.showAlert("请选择要查看的嘱托！");
            }
        }

        //音频播放
        vm.audioPlaying = false;
        $scope.playAudio = function(audioPath,divId){
            var audio = $("audio[name='"+divId+"']")[0];
            var interval;
            if(AppUtils.isUndefinedOrNull(audio)){
                var entrustBox = $("#" + divId);
                entrustBox.addClass("entrust-audio-loading");
                var audioHtml = '<audio name="'+ divId +'" src="'+ $sce.trustAsResourceUrl(audioPath) +'" controls style="display: none;"></audio>';
                $("#audioBox").append(audioHtml);
                audio = $("audio[name='"+divId+"']")[0];
                //音频可以加载至播放
                audio.addEventListener("playing", function() {
                    var nprogress = entrustBox.find(".audio-nprogress")[0];
                    var duration = Math.ceil(audio.duration*500);//总毫秒数
                    var count = duration/50;
                    var i = 100/count * 1000;
                    var s = 0;
                    interval = $interval(function(){
                        s = s + i;
                        nprogress.style.width =  s/1000 + "%";
                    }, 50, count);
                    entrustBox.find("button").removeClass("ion-play").addClass("ion-pause");
                }, false);
                //音频可以播放完毕
                audio.addEventListener("ended", function() {
                    $timeout(function(){
                        entrustBox.find("button").removeClass("ion-pause").addClass("ion-play");
                        entrustBox.find(".audio-nprogress")[0].style.width = "0%";
                        $interval.cancel(interval);
                        vm.audioPlaying = false;
                    },200)
                }, false);
                audio.addEventListener("canplay", function() {
                    entrustBox.removeClass("entrust-audio-loading");
                    vm.audioPlaying = true;
                    audio.play();
                }, false);
            }else{
                audio.play();
            }
        }

        //悬浮菜单
        $("#hamburgerMenuBtn").on("click",function () {
            $("#hamburgerMenuBtn").toggleClass("active");
        });

        var lastTop = 0;
        $scope.scrollFun = function(){
            var top = $ionicScrollDelegate.$getByHandle('entrustScroll').getScrollPosition().top;
            if(top > 200 && top > lastTop){
                $("#hamburgerMenuBtn").removeClass("active");
                $("#hamburgerMenuBtn").css("right","-80px")
            }else if(lastTop - top > 20){
                $("#hamburgerMenuBtn").css("right","40px")
            }
            lastTop = top;
        }
    }

})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    TeacherEntrustCtrl.$inject = ["$scope", "$state", "AppUtils", "EntrustService", "$timeout", "$interval", "$sce", "LoginAccountAuth", "$ionicScrollDelegate"];
    angular.module('App.pages.member.entrust')
        .controller('TeacherEntrustCtrl', TeacherEntrustCtrl);


    function TeacherEntrustCtrl($scope,$state,AppUtils,EntrustService,$timeout,$interval,$sce,LoginAccountAuth,$ionicScrollDelegate) {

        var vm = this;
        vm.entrustTitle = "嘱托列表";
        vm.isUnsolved = true;
        vm.unsolvedExhortaions = [];
        vm.solvedExhortaions = [];
        vm.unsolvedPageIndex = 0;
        vm.solvedPageIndex = 0;
        vm.exhortaions = [];
        vm.loadUnsolvedExhortaionsFlag = 'loading';//neverLoad|loadFinish|loading
        vm.loadSolvedExhortaionsFlag = 'neverLoad';
        vm.loadMoreUnsolvedBtnStatus = true;
        vm.loadMoreSolvedStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.entrustStatusParams = 'unexecuted';//unexecuted待办嘱托状态,executed为已办嘱托状态
        vm.sortType = 'entrustTime';
        vm.pageIndex = 1;//第一页

        //切换不同嘱托状态列表
        $scope.changeStatus = function(status) {
            vm.exhortaions = [];
            if($scope.isUnsolved != status){
                if(status == true){
                    vm.isUnsolved = true;
                    vm.entrustTitle = "待办列表";
                    vm.entrustStatusParams = 'unexecuted';
                    vm.sortType = 'entrustTime';
                    if(vm.loadUnsolvedExhortaionsFlag == 'neverLoad'){
                        vm.pageIndex = 1;//第一页
                        $scope.loadMoreEntrust();
                        console.log(111111111111111);
                    }else if(vm.loadUnsolvedExhortaionsFlag == 'loading'){
                        vm.loadMoreUnsolvedBtnStatus = true;
                    }else if(vm.loadUnsolvedExhortaionsFlag == 'loadFinish'){
                        vm.loadMoreUnsolvedBtnStatus = false;
                    }
                }else if(status == false){
                    vm.isUnsolved = false;
                    vm.entrustTitle = "已办列表";
                    vm.entrustStatusParams = 'execute';
                    vm.sortType = 'executeTime';
                    if(vm.loadSolvedExhortaionsFlag == 'neverLoad'){
                        vm.pageIndex = 1;//第一页
                        $scope.loadMoreEntrust();
                    }else if(vm.loadSolvedExhortaionsFlag == 'loading'){
                        vm.loadMoreSolvedStatus = true;
                        vm.loadMoreBtnStr = "加载更多";
                    }else if(vm.loadSolvedExhortaionsFlag == 'loadFinish'){
                        vm.loadMoreSolvedStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                }
                //AppUtils.scrollTop();
            }
        }


        LoginAccountAuth.getAccount()
            .then(function(data){
                vm.loginAccount = data;
                vm.getEntrustPage();
            });

        //往上拉加载更多
        $scope.loadMoreEntrust = function(){
            if(vm.entrustStatusParams == 'unexecuted' && vm.loadMoreUnsolvedBtnStatus == true){
                vm.pageIndex = vm.unsolvedPageIndex + 1;
                vm.getEntrustPage();
            }else if(vm.entrustStatusParams == 'execute' && vm.loadMoreSolvedStatus == true){
                vm.pageIndex = vm.solvedPageIndex + 1;
                vm.getEntrustPage();
            }
        }


        vm.getEntrustPage = function(){
            var params = {};
            params.entrustState = vm.entrustStatusParams;
            params.pageInfo = {};
            params.pageInfo.pageSize = 10;
            params.pageInfo.pageNumber = vm.pageIndex;

            EntrustService.loadEntrustPage(params).then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStr = "没有更多数据了";
                        if(vm.entrustStatusParams == 'unexecuted'){
                            vm.loadUnsolvedExhortaionsFlag = 'loadFinish';//不再加载待办嘱托列表数据
                            vm.loadMoreUnsolvedBtnStatus = false;
                        }else if(vm.entrustStatusParams == 'execute'){
                            vm.loadSolvedExhortaionsFlag = 'loadFinish';//不再加载已办嘱托列表数据
                            vm.loadMoreSolvedStatus = false;
                        }
                    }
                    if(vm.entrustStatusParams == 'unexecuted'){
                        vm.unsolvedPageIndex = pageIndex;
                        angular.forEach(items,function(data,index,array){
                            vm.unsolvedExhortaions.push(data);
                        })
                    }else{
                        if(vm.loadSolvedExhortaionsFlag != 'loadFinish'){
                            vm.loadSolvedExhortaionsFlag = 'loading';
                        }
                        vm.solvedPageIndex = pageIndex;
                        angular.forEach(items,function(data,index,array){
                            vm.solvedExhortaions.push(data);
                        })
                    }
                }
            }).finally(function() {
                $scope.$broadcast('scroll.infiniteScrollComplete');
            });
        }
    }

})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    MemberEditCtrl.$inject = ["$scope", "MemberModel", "LoginAccountAuth", "AppUtils", "$filter"];
    angular.module('App.pages.class')
        .controller('MemberEditCtrl', MemberEditCtrl);

    function MemberEditCtrl($scope,MemberModel,LoginAccountAuth,AppUtils,$filter) {

        var vm = this;
        vm.memberVo = {};
        vm.birthday;
        vm.loginAccountVo = {};
        LoginAccountAuth.getAccount().then(function(data){
            vm.loginAccountVo = data;
            MemberModel.getMemberInfo({id:data.memberId}).$promise.then(function(response){
                if(!AppUtils.isUndefinedOrNull(response.memberInfo)){
                    vm.memberVo = response.memberInfo;
                    vm.memberVo.memberBirthday = new Date(vm.memberVo.memberBirthday);
                }else {
                    AppUtils.showTipsTop("未查询到成员信息！");
                }
            })
        })

        $scope.commit = function(){
            MemberModel.saveParentMemberInfo(vm.memberVo).$promise.then(function(response){
                var result = response.result;
                if(!AppUtils.isUndefinedOrNull(result) && result == 'success'){
                    AppUtils.showTipsTop("保存成员信息成功！");
                }else{
                    AppUtils.showTipsTop("保存失败！");
                }
            });
        }

    }
})();

/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ParentCtrl.$inject = ["$scope", "$state", "$ionicSlideBoxDelegate", "AppUtils", "LoginAccountAuth", "MsgModel", "EntrustModel", "MsgService"];
    angular.module('App.pages.member')
        .controller('ParentCtrl', ParentCtrl);

    function ParentCtrl($scope,$state,$ionicSlideBoxDelegate,AppUtils,LoginAccountAuth,MsgModel,EntrustModel,MsgService) {

        var vm = this;
        $scope.next = function() {
            $ionicSlideBoxDelegate.next();
        };
        $scope.previous = function() {
            $ionicSlideBoxDelegate.previous();
        };
        $scope.slideChanged = function(index) {
            $scope.slideIndex = index;
        };
        $ionicSlideBoxDelegate.loop(true); //解决轮播至最后一个不轮播的问题

        var vm = this;
        vm.exhortaions = [];
        vm.loadMoreBtnStatus = true;
        vm.loadMoreBtnStr = "加载更多";
        vm.pageIndex = 0;

        $scope.loadMoreMsg = function(){
            if(vm.loadMoreBtnStatus){
                vm.pageIndex = vm.pageIndex + 1;
                vm.getMsgPage();
            }
        }

        vm.getMsgPage = function(){
            var params = {};
            params.pageInfo = {};
            params.pageInfo.pageSize = 10;
            params.pageInfo.pageNumber = vm.pageIndex;

            MsgService.loadMsgPage(params).then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var reponseDate = response.pageResult;
                    var items = reponseDate.pageResult;
                    var pageIndex = reponseDate.pageIndex;
                    var pageTotalPageSize = reponseDate.pageTotalPageSize;
                    if(pageIndex == pageTotalPageSize || items.length == 0){
                        vm.loadMoreBtnStatus = false;
                        vm.loadMoreBtnStr = "没有更多数据了";
                    }
                    angular.forEach(items,function(data){
                        vm.exhortaions.push(data);
                    })
                }
            }).finally(function() {
                // Stop the ion-refresher from spinning
                $scope.$broadcast('scroll.infiniteScrollComplete');
            });
        }
    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ParentInfoCtrl.$inject = ["studentId", "$scope", "AppUtils", "MemberModel", "$ionicPopup", "$window", "store", "Global"];
    angular.module('App.pages.member')
        .controller('ParentInfoCtrl', ParentInfoCtrl);

    function ParentInfoCtrl(studentId,$scope,AppUtils,MemberModel,$ionicPopup,$window,store,Global) {
        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });

        $scope.studentId = studentId;

        var vm = this;
        vm.memberInfoNotChange = true;
        vm.memberEdit = false;
        vm.disableLeavenMsgBtn = false;
        vm.memberInfo = {};

        $scope.change = function(){
            vm.memberInfoIsChange = false;
        }

        vm.loginAccount = store.get("loginAccount");
        vm.showLeaveMsgBtn = false;
        if(!AppUtils.isUndefinedOrNull(vm.loginAccount)){
            if(vm.loginAccount.memberType == '1'){
                vm.showLeaveMsgBtn = true;
            }
        }



        $scope.goBack = function(){
            if(vm.memberEdit == true){
                var confirmPopup = $ionicPopup.confirm({
                    title: "提示",
                    template: "是否退出家长信息修改？",
                    buttons: [
                        {
                            text: '是',
                            onTap: function() {
                                vm.memberEdit = false;
                            }
                        },
                        {
                            text: '<b>否</b>',
                            type: 'button-positive',
                            onTap: function() {
                                vm.memberEdit = true;
                            }
                        }
                    ]
                });
            }else{
                $window.history.go(-1);
            }
        }


        $scope.editMemberInfo = function(){
            if(vm.memberEdit == true){
                var confirmPopup = $ionicPopup.confirm({
                    title: "提示",
                    template: "是否退出家长信息修改？",
                    buttons: [
                        {
                            text: '是',
                            onTap: function() {
                                vm.memberEdit = false;
                            }
                        },
                        {
                            text: '<b>否</b>',
                            type: 'button-positive',
                            onTap: function() {
                                vm.memberEdit = true;
                            }
                        }
                    ]
                });
            }else{
                vm.memberEdit = true;
            }
        }

        //parentId = "A83FA905F6044E9CA30C52FDCD351794";
        var memberType = "2";

        $scope.studentInfo = {};
        $scope.fatherInfo = {};
        $scope.motherInfo = {};

        vm.init = function(){
            if(!AppUtils.isUndefinedOrNull(studentId)){
                MemberModel.getParentInfo({id: studentId}).$promise.then(function(response){
                    if(response.stat == 'err'){
                        AppUtils.showAlert(response.msg);
                    }else{
                        if(AppUtils.isUndefinedOrNull(response.memberList)){
                            AppUtils.showAlert("未找到此家长信息");
                            AppUtils.goBack();
                        }else{
                            angular.forEach(response.memberList,function(obj){
                                if(obj.memberType == '3'){
                                    $scope.studentInfo = obj;
                                    if(AppUtils.isUndefinedOrNull(obj.avatarPath)){
                                        $scope.studentInfo.avatarPath = Global.default_avatarPath;
                                    }
                                }else if(obj.memberType == '2'){
                                    if(obj.memberRelType == 'father'){
                                        $scope.fatherInfo = obj;
                                    }else if(obj.memberRelType == 'mother'){
                                        $scope.motherInfo = obj;

                                    }
                                }
                            })
                        }
                    }
                })
            }else{
                AppUtils.showAlert("未找到家长信息！");
            }
        }
        vm.init();
        $scope.submit = function() {
            if(AppUtils.isUndefinedOrNull(vm.memberInfo.memberName)){
                AppUtils.showAlert("请输入家长姓名！");
                return false;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberInfo.memberPhone)){
                AppUtils.showAlert("请输入家长手机号码！");
                return false;
            }
            if(AppUtils.isUndefinedOrNull(vm.memberInfo.memberAddress)){
                AppUtils.showAlert("请输入家长居住地址！");
                return false;
            }

            MemberModel.saveParentMemberInfo(vm.memberInfo).$promise.then(function(response){
                var result = response.result;
                if(!AppUtils.isUndefinedOrNull(result) && result == 'success'){
                    AppUtils.showAlert("保存家长信息成功！");
                    vm.memberEdit = false;
                }else{
                    AppUtils.showAlert("保存失败！");
                }

            })
        };
    }
})();

/**
 * Created by leon on 2017/5/8.
 */
(function () {
    'use strict';
    ChangeRalCtrl.$inject = ["id", "$scope", "MemberModel", "AppUtils"];
    angular.module('App.pages.member')
        .controller('ChangeRalCtrl',ChangeRalCtrl);
    function ChangeRalCtrl(id,$scope,MemberModel,AppUtils){
        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });
        var vm = this;
        vm.name="";

        vm.test = function (obj) {
            vm.name=obj;

        }
        var objParams={};


        // objParams.memberId='A83FA905F6044E9CA30C52FDCD351794';
        objParams.memberId=id;
        $scope.save=function () {
            objParams.relType=vm.name;
            if(AppUtils.isUndefinedOrNull(objParams)){
                AppUtils.showAlert("请选择亲属关系！");
                return false;
            }

            MemberModel.changeRel(objParams).$promise.then(function(response){
                var result = response.result;
                if(!AppUtils.isUndefinedOrNull(result) && result == 'success'){
                    AppUtils.showAlert("更改成功！");
                    // AppUtils.goBack();
                }
            })
        }

    }
})();
/**
 * Created by leon on 2017/4/27.
 */
(function () {
    'use strict';

    MemberOfFamilyCtrl.$inject = ["id", "$scope", "MemberModel", "$location", "$state"];
    angular.module('App.pages.member')
        .controller('MemberOfFamilyCtrl', MemberOfFamilyCtrl);

    function MemberOfFamilyCtrl(id,$scope,MemberModel,$location,$state) {

        $scope.$on('$ionicView.beforeEnter', function (event, viewData) {
            viewData.enableBack = true;
        });




        var vm = this;
        var objParams={};
        $scope.studentInfo = {};
        $scope.relType = {};
        objParams.id='A83FA905F6044E9CA30C52FDCD351794';

        MemberModel.getStudentInfoByParentId(objParams).$promise.then(function(response){
            if(response.stat == 'err'){
                AppUtils.showAlert(response.msg);
            }else{
                vm.studentInfo=response.studentInfo;
                vm.relType=response.relType;
            }
        });

        // MemberModel.getMemberInfo(objParams).$promise.then(function(response){
        //     if(response.stat == 'err'){
        //         AppUtils.showAlert(response.msg);
        //     }else{
        //         vm.memberInfo = response.memberInfo;
        //         console.info(response.memberInfo);
        //     }
        // });
        // $scope.stduentInfo={};
        // objParams.stduentId=studentId;
        // MemberModel.findStudentByParentId(objParams).$promise.then(function (response) {
        //     if(response.stat == 'err'){
        //         AppUtils.showAlert(response.msg);
        //     }else{
        //         vm.studentInfo = response.studentInfo;
        //         console.info(response.studentInfo);
        //     }
        // });
        // $scope.familyInfo={};
        vm.familyInfo = [];
        var obj={};
        obj.memberId= '8F0E9C2C8C2B96498EE8AF60E205838E';
        MemberModel.getfamilyInfo(obj).$promise.then(function(response){
            // if(response.stat == 'err'){
            //     AppUtils.showAlert(response.msg);
            // }else{
                vm.familyInfo=response.familyInfo;
                console.info(vm.familyInfo);
            // }
        });

        $scope.jumpToUrl=function () {
            alert("111");
            // var path='http://192.168.1.173/wechat/#/member/changeRel/A83FA905F6044E9CA30C52FDCD351794';

            // window.location=(path);
            $location.path("/member/changeRel/A83FA905F6044E9CA30C52FDCD351794");
            var curUrl = $state.absUrl();

        }
    }
})();
/**
 * Created by leon on 2017/5/9.
 */
(function () {
    'use strict';
    MineMenuCtrl.$inject = ["$scope", "MemberModel", "AppUtils", "$location"];
    angular.module('App.pages.member')
        .controller('MineMenuCtrl',MineMenuCtrl);
    function MineMenuCtrl($scope,MemberModel,AppUtils,$location) {
        var vm = this;
        // vm.memberId=memberId;
        var objParams={};
        objParams.id='A83FA905F6044E9CA30C52FDCD351794';
        MemberModel.getMemberInfo(objParams).$promise.then(function(response){
            if(response.stat == 'err') {
                AppUtils.showAlert(response.msg);
            }else{
                vm.memberInfo = response.memberInfo;
            }
        })

        $scope.jumpToUrl=function (path,type) {
            console.info($(type));
            // document.getElementById(type).value().addClass("background-color:#ccc");

            // window.location=(path);
            $location.path(path);
        }
    }
})();
/**
 * Created by leon on 2017/5/10.
 */
(function () {
    'use strict';

    MyInfoCtrl.$inject = ["$scope", "MemberModel"];
    angular.module('App.pages.member')
        .controller('MyInfoCtrl',MyInfoCtrl);
    function MyInfoCtrl($scope,MemberModel) {

        var vm = this;
        var objParams={};
        objParams.id='A83FA905F6044E9CA30C52FDCD351794';
        MemberModel.getMemberInfo(objParams).$promise.then(function(response){
            if(response.stat == 'err') {
                AppUtils.showAlert(response.msg);
            }else{
                vm.memberInfo = response.memberInfo;
            }
        })

        $scope.turnTo=function (){
            angular.element(".numberOne").css("display","none");
            angular.element(".numberTwo").css("display","block");
            angular.element(".numberThree").css("display","none");
        }

        $scope.turnB=function(){
            angular.element(".numberOne").css("display","none");
            angular.element(".numberTwo").css("display","none");
            angular.element(".numberThree").css("display","block");
        }



        $scope.cancel=function () {
            angular.element(".numberOne").css("display","block");
            angular.element(".numberTwo").css("display","none");
            angular.element(".numberThree").css("display","none");
        }

        $scope.updateInfo=function () {
            objParams.memberName=vm.Name;
            if(objParams.memberName==null){
                AppUtils.showAlert("您没有输入姓名,请重新输入！");
            }else {
                MemberModel.Modify(objParams).$promise.then(function(response){
                    if(response.stat == 'err') {
                        AppUtils.showAlert(response.msg);
                    }else{
                        angular.element(".numberOne").css("display","block");
                        angular.element(".numberTwo").css("display","none");
                        angular.element(".numberThree").css("display","none");
                        AppUtils.showAlert(response.msg);
                    }
                })
            }
        }


        $scope.updatePhone=function () {
            objParams.phone=vm.phoneNumber;
            if(objParams.phone==null){
                AppUtils.showAlert("您没有输入手机号码，请重新输入！");
            }else{

                MemberModel.Modify(objParams).$promise.then(function(response){
                    if(response.stat == 'err') {
                        AppUtils.showAlert(response.msg);
                    }else{
                        angular.element(".numberOne").css("display","block");
                        angular.element(".numberTwo").css("display","none");
                        angular.element(".numberThree").css("display","none");
                        AppUtils.showAlert(response.msg);
                    }
                })
            }
        }
    }
})();
/**
 * Created by hxpeng on 2017/5/11.
 */
(function () {
    'use strict';

    AddStudentCtrl.$inject = ["AppUtils", "$scope", "$http", "MemberModel", "$location", "Global", "$state", "$timeout", "LoginAccountAuth"];
    angular.module('App.pages.member')
        .controller('AddStudentCtrl', AddStudentCtrl);

    function AddStudentCtrl(AppUtils,$scope,$http,MemberModel,$location,Global,$state,$timeout,LoginAccountAuth) {
        var vm = this;
        vm.showScanQRCode = true;
        vm.showConfirm = false;
        vm.student = {};

        var currentPath = $location.url();
        if(currentPath.indexOf("#") != -1){
            currentPath = currentPath.split('#')[0];
        }
        currentPath = Global.path.wechat_path + currentPath;
        $http.post(Global.path.server_sdk_auth_path,{"url":currentPath})
            .success(function(data){
                wx.config({
                    debug: false,
                    appId: data.appId,
                    timestamp: data.timestamp,
                    nonceStr: data.noncestr,
                    signature: data.signature,
                    jsApiList: ['scanQRCode']
                });
                wx.error(function(res){
                    console.log(res);
                });
            })
            .error(function(data,header,config,status){
                alert("请求微信sdk校验异常");
            });

        //var result = '{"memberId":"041DFD58D85D31A478B881F1EBE4ECA9","memberName":"吴永琪","memberBirthday":"2007-05-11 16:22:33","avatarPath":"http://www.hxpeng.com/images/user/aaaaa.png","studentNumber":1}';
        ////var result = "{memberId:dwdawdawdawda}"
        //
        //if(!AppUtils.isUndefinedOrNull(result)){
        //    var obj = JSON.parse(result);
        //    if(!AppUtils.isUndefinedOrNull(obj) || !AppUtils.isUndefinedOrNull(obj.memberId)){
        //        vm.student = obj;
        //        vm.showConfirm = true;
        //    }
        //}

        //打开扫码
        $scope.scanQRCode = function(){
            wx.scanQRCode({
                needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                success: function (res) {
                    //获得二维码的json数据
                    var result = res.resultStr;
                    //var result = '{"memberId":"041DFD58D85D31A478B881F1EBE4ECA9","memberName":"吴永琪","memberBirthday":"2007-05-11 16:22:33","avatarPath":"http://www.hxpeng.com/images/user/aaaaa.png","studentNumber":1}';

                    if(!AppUtils.isUndefinedOrNull(result)){
                        var obj = JSON.parse(result);
                        if(!AppUtils.isUndefinedOrNull(obj) || !AppUtils.isUndefinedOrNull(obj.memberId)){
                            vm.showScanQRCode = false;
                            $timeout(function(){
                                vm.student = obj;
                            },0)
                            vm.showConfirm = true;
                        }
                    }else{
                        AppUtils.showAlert("请扫描正确的二维码！");
                    }
                }
            });
        }


        //提交绑定
        $scope.submitInfo = function(){
            if(!AppUtils.isUndefinedOrNull(vm.student.memberId)){
                MemberModel.studentBindParent({memberId : vm.student.memberId}).$promise.then(function(response) {
                    if(!AppUtils.isUndefinedOrNull(response) && response.stat == 'success'){
                        $location.path("/");
                        AppUtils.showAlert("添加成功！");
                        LoginAccountAuth.setAccount(response.loginAccountVo);
                    }else if(response.stat == 'err'){
                        AppUtils.showAlert(response.msg);
                    }else{
                        AppUtils.showAlert("提交失败，请稍后再试！");
                    }
                });
            }else{
                AppUtils.showAlert("提交失败，刷新页面试试！");
            }

        }


    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    ChooseStudentCtrl.$inject = ["AppUtils", "MemberModel", "$stateParams", "$state", "$scope"];
    angular.module('App.pages.member')
        .controller('ChooseStudentCtrl', ChooseStudentCtrl);

    function ChooseStudentCtrl(AppUtils,MemberModel,$stateParams,$state,$scope) {
        var vm = this;
        vm.studentList = [];
        vm.noData = false;
        vm.nextState = $stateParams.nextState;

        var params = {};
        params.memberId = "11111";
        params.pageInfo = {};
        params.pageInfo.pageSize = 100;
        params.pageInfo.pageNumber = 1;
        MemberModel.getStudentList(params).$promise.then(function(response){
            if(response.stat == 'err'){
                AppUtils.showTipsTop("加载学生列表失败！");
            }else{
                var reponseDate = response.pageResult;
                var items = reponseDate.pageResult;
                if(items.length == 0){
                    vm.noData = true;
                }
                vm.studentList = _.clone(items);
            }
        })


        $(".entrust-create-screen").on("click",".card-facebook",function(e){
            $(this).find(".ion").toggleClass('ion-android-done');
        })

        $("#chooseAllStudentBtn").click(function(){
            if($(this).hasClass("ion-android-checkbox-outline")){
                $(this).removeClass("ion-android-checkbox-outline");
                $(this).addClass("ion-android-checkbox-outline-blank");
                $(".container").find(".ion").removeClass("ion-android-done");
            }else{
                $(this).addClass("ion-android-checkbox-outline");
                $(this).removeClass("ion-android-checkbox-outline-blank");
                $(".container").find(".ion").addClass("ion-android-done");
            }
        })

        $scope.next = function(){
            var studentArray = [];
            var resutArray = $(".container").find(".ion-android-done");
            if(resutArray.length < 1){
                AppUtils.showTipsTop("请选择学生留言！");
                return;
            }
            resutArray.each(function(){
                var studentId = $(this).attr("data-studentId");
                if(!AppUtils.isUndefinedOrNull(studentId)){
                    studentArray.push(studentId);
                }
            })
            $state.go(vm.nextState,{studentArray:studentArray});
        }


    }
})();
/**
 * Created by hxpeng on 2017/3/24.
 */
(function () {
    'use strict';

    StudentClassCtrl.$inject = ["studentId", "AppUtils", "$scope", "MemberModel"];
    angular.module('App.pages.member')
        .controller('StudentClassCtrl', StudentClassCtrl);

    function StudentClassCtrl(studentId,AppUtils,$scope,MemberModel) {
        if(AppUtils.isUndefinedOrNull(studentId)){
            AppUtils.showTipsTop("请选择一个宝宝操作！");
            AppUtils.goBack();
        }

    }
})();